Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-05-13 18:24:38
Exec Total Coverage
Lines: 1790 4300 41.6%
Functions: 131 350 37.4%
Branches: 958 2730 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include "combos.h"
67 #include <fmt/format.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 extern FFScript FFCore;
74 extern bool Playing;
75 int32_t sfx_voice[WAV_COUNT];
76 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
77 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82835 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 d[i].dp2 = get_zc_font(font_lfont_l);
254 }
255 else if(!bigfontproc)
256 {
257 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 bool is_reserved_key(int c)
285 {
286 switch(c)
287 {
288 case KEY_ESC:
289 return true;
290 }
291 return false;
292 }
293 bool is_reserved_keycombo(int c, int modflag)
294 {
295 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
296 return true;
297 return false;
298 }
299 bool checkcheat(Cheat cheat)
300 {
301 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
302 return true; //Main key pressed
303 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
304 return true; //Alt key pressed
305 return false;
306 }
307 33 void load_default_cheatkeys()
308 {
309 33 memset(cheatkeys, 0, sizeof(cheatkeys));
310 33 cheatkeys[Cheat::Life][0] = KEY_H;
311 33 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
312 33 cheatkeys[Cheat::Magic][0] = KEY_M;
313 33 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
314 33 cheatkeys[Cheat::Rupies][0] = KEY_R;
315 33 cheatkeys[Cheat::Bombs][0] = KEY_B;
316 33 cheatkeys[Cheat::Arrows][0] = KEY_A;
317 33 cheatkeys[Cheat::Clock][0] = KEY_I;
318 33 cheatkeys[Cheat::Walls][0] = KEY_F11;
319 33 cheatkeys[Cheat::Fast][0] = KEY_Q;
320 33 cheatkeys[Cheat::Light][0] = KEY_L;
321 33 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
322 33 cheatkeys[Cheat::Kill][0] = KEY_K;
323 33 cheatkeys[Cheat::GoTo][0] = KEY_G;
324 33 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
325 33 cheatkeys[Cheat::ShowL0][0] = KEY_0;
326 33 cheatkeys[Cheat::ShowL1][0] = KEY_1;
327 33 cheatkeys[Cheat::ShowL2][0] = KEY_2;
328 33 cheatkeys[Cheat::ShowL3][0] = KEY_3;
329 33 cheatkeys[Cheat::ShowL4][0] = KEY_4;
330 33 cheatkeys[Cheat::ShowL5][0] = KEY_5;
331 33 cheatkeys[Cheat::ShowL6][0] = KEY_6;
332 33 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
333 33 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
334 33 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
335 33 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
336 33 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
337 33 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
338 33 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
339 33 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
340 33 }
341 33 void load_game_configs()
342 {
343 33 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
344 33 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
345 33 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
346 33 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
347 33 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
348 33 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
349 33 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
350 33 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
351 33 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
352 33 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
353 33 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
354 33 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
355 33 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
356 33 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
357 33 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
358
359 //cheat modifier keya
360 33 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
361 33 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
362 33 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
363 33 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
364
365 //cheat keys
366 33 load_default_cheatkeys();
367 char buf[256];
368
2/2
✓ Branch 0 taken 1155 times.
✓ Branch 1 taken 33 times.
1188 for(size_t q = 1; q < Cheat::Last; ++q)
369 {
370
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if(!bindable_cheat((Cheat)q)) continue;
371 1155 std::string cheatname = cheat_to_string((Cheat)q);
372
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 util::lowerstr(cheatname);
373 1155 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
374
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
375 1155 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
376
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
377 1155 }
378
379
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
380 joystick_index = 0;
381
382 33 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
383 33 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
384 33 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
385 33 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
386 33 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
387 33 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
388 33 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
389 33 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
390 33 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
391 33 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
392
393 33 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
394 33 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
395 33 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
396 33 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
397
398 33 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
399 33 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
400 33 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
401 33 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
402 33 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
403 33 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
404 33 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
405 33 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
406 33 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
407 33 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
408 33 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
409
410 33 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
411 33 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
412 33 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
413 33 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
414
415 33 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
416
417 33 digi_volume = zc_get_config(sfx_sect,"digi",248);
418 33 midi_volume = zc_get_config(sfx_sect,"midi",255);
419 33 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
420 33 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
421 33 pan_style = zc_get_config(sfx_sect,"pan",1);
422 // 1 <= zcmusic_bufsz <= 128
423 33 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
424 33 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
425 33 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
426 33 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
427 33 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
428 33 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
429 33 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
430 #ifdef __EMSCRIPTEN__
431 if (em_is_mobile()) NameEntryMode = 2;
432 #endif
433 33 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
434 33 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
435 33 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
436 33 title_version = zc_get_config(cfg_sect,"title",2);
437 33 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
438 33 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
439
440 //default - scale x2, 640 x 480
441 33 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
442 33 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
443 33 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
444 33 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
445 33 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
446 33 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
447 33 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
448
449 33 loadlast = zc_get_config(cfg_sect,"load_last",0);
450
451 33 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
452
453 33 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
454
455 33 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
456 33 info_opacity = zc_get_config("zc","debug_info_opacity",255);
457 #ifdef _WIN32
458 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
461 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
462
463 // This one's for Aero
464 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
465
466 // And this one fixes patches unloading on some MIDI setups
467 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
468 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
469 #else //UNIX
470 33 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
471 33 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
472 33 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
473 #endif
474 33 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
475 33 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
476
477 33 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
478
479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(strlen(qstdir)==0)
480 {
481 33 getcwd(qstdir,2048);
482 33 fix_filename_case(qstdir);
483 33 fix_filename_slashes(qstdir);
484 33 put_backslash(qstdir);
485 33 }
486 else
487 {
488 chop_path(qstdir);
489 }
490
491 33 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
492 33 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
493 33 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
494 33 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
495 33 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
496 33 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
497 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
498 33 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
499 33 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
500 33 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
501 33 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
502 33 }
503
504 void save_control_configs(bool kb)
505 {
506 if(kb)
507 {
508 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
509 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
510 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
511 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
512
513 if (!replay_is_replaying())
514 {
515 zc_set_config(ctrl_sect,"key_a",Akey);
516 zc_set_config(ctrl_sect,"key_b",Bkey);
517 zc_set_config(ctrl_sect,"key_s",Skey);
518 zc_set_config(ctrl_sect,"key_l",Lkey);
519 zc_set_config(ctrl_sect,"key_r",Rkey);
520 zc_set_config(ctrl_sect,"key_p",Pkey);
521 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
522 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
523 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
524 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
525 zc_set_config(ctrl_sect,"key_up", DUkey);
526 zc_set_config(ctrl_sect,"key_down", DDkey);
527 zc_set_config(ctrl_sect,"key_left", DLkey);
528 zc_set_config(ctrl_sect,"key_right",DRkey);
529 }
530 }
531 else
532 {
533 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
534 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
535 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
536 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
538 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
539 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
540 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
541 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
542 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
543 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
544 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
545 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
546 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
547
548 zc_set_config(ctrl_sect,"btn_a",Abtn);
549 zc_set_config(ctrl_sect,"btn_b",Bbtn);
550 zc_set_config(ctrl_sect,"btn_s",Sbtn);
551 zc_set_config(ctrl_sect,"btn_m",Mbtn);
552 zc_set_config(ctrl_sect,"btn_l",Lbtn);
553 zc_set_config(ctrl_sect,"btn_r",Rbtn);
554 zc_set_config(ctrl_sect,"btn_p",Pbtn);
555 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
556 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
557 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
558 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
559
560 zc_set_config(ctrl_sect,"btn_up",DUbtn);
561 zc_set_config(ctrl_sect,"btn_down",DDbtn);
562 zc_set_config(ctrl_sect,"btn_left",DLbtn);
563 zc_set_config(ctrl_sect,"btn_right",DRbtn);
564 }
565 }
566
567 void save_cheatkeys()
568 {
569 char buf[256];
570 for(size_t q = 1; q < Cheat::Last; ++q)
571 {
572 if(!bindable_cheat((Cheat)q)) continue;
573 std::string cheatname = cheat_to_string((Cheat)q);
574 util::lowerstr(cheatname);
575 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
576 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
577 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
578 if(cheatkeys[q][1])
579 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
580 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
581 }
582 }
583
584 void save_game_configs()
585 {
586 packfile_password("");
587
588 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
589
590 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
591 {
592 int o_window_x, o_window_y;
593 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
594 zc_set_config(cfg_sect,"window_x",o_window_x);
595 zc_set_config(cfg_sect,"window_y",o_window_y);
596 }
597
598 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
599 {
600 double monitor_scale = zc_get_monitor_scale();
601 window_width = al_get_display_width(all_get_display()) / monitor_scale;
602 window_height = al_get_display_height(all_get_display()) / monitor_scale;
603 zc_set_config(cfg_sect,"window_width",window_width);
604 zc_set_config(cfg_sect,"window_height",window_height);
605 }
606
607 zc_set_config(cfg_sect,"load_last",loadlast);
608 chop_path(qstdir);
609 zc_set_config(cfg_sect,qst_dir_name,qstdir);
610 zc_set_config("SAVEFILE","save_filename",save_file_name);
611 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
612
613 flush_config_file();
614 #ifdef __EMSCRIPTEN__
615 em_sync_fs();
616 #endif
617 }
618
619 //----------------------------------------------------------------
620
621 // Timers
622
623 35517 void fps_callback()
624 {
625 35517 lastfps=framecnt;
626 35517 dword tempsecs = fps_secs;
627 35517 ++tempsecs;
628 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
629 35517 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
630 35517 ++fps_secs;
631 35517 framecnt=0;
632 35517 }
633
634 END_OF_FUNCTION(fps_callback)
635
636 33 int32_t Z_init_timers()
637 {
638 static bool didit = false;
639 const static char *err_str = "Couldn't allocate timer";
640 33 err_str = err_str; //Unused variable warning
641
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(didit)
643 return 1;
644
645 33 didit = true;
646
647 LOCK_VARIABLE(lastfps);
648 LOCK_VARIABLE(framecnt);
649 LOCK_FUNCTION(fps_callback);
650
651
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
652 return 0;
653
654 33 return 1;
655 33 }
656
657 void Z_remove_timers()
658 {
659 remove_int(fps_callback);
660 }
661
662 //----------------------------------------------------------------
663
664 void go()
665 {
666 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
667 }
668
669 void comeback()
670 {
671 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
672 }
673
674 void dump_pal(BITMAP *dest)
675 {
676 for(int32_t i=0; i<256; i++)
677 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
678 }
679
680 //----------------------------------------------------------------
681
682 int game_mouse_index = ZCM_BLANK;
683 static bool system_mouse = false;
684 28 bool sys_mouse()
685 {
686 28 system_mouse = true;
687 28 return MouseSprite::set(ZCM_NORMAL);
688 }
689 457 bool game_mouse()
690 {
691 457 system_mouse = false;
692 457 return MouseSprite::set(game_mouse_index);
693 }
694 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
695 {
696 if(!bmp)
697 return;
698 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
699 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
700 if(bmp->w == scaledw && bmp->h == scaledh)
701 user_scale = false;
702 if(user_scale || sys_recolor)
703 {
704 if(!user_scale) scale = 1;
705 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
706 if(user_scale)
707 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
708 else
709 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
710 if(sys_recolor)
711 recolor_mouse(tmpbmp);
712 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
713 destroy_bitmap(tmpbmp);
714 }
715 else
716 {
717 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
718 }
719 }
720
721 //Handles converting the mouse sprite from the .dat file
722 33 void recolor_mouse(BITMAP* bmp)
723 {
724
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 33 times.
561 for(int32_t x = 0; x < bmp->w; ++x)
725 {
726
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 528 times.
8976 for(int32_t y = 0; y < bmp->h; ++y)
727 {
728 8448 int32_t color = getpixel(bmp, x, y);
729
5/5
✓ Branch 0 taken 5742 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 759 times.
✓ Branch 4 taken 594 times.
8448 switch(color)
730 {
731 case dvc(1):
732 627 color = jwin_pal[jcCURSORMISC];
733 627 break;
734 case dvc(2):
735 726 color = jwin_pal[jcCURSOROUTLINE];
736 726 break;
737 case dvc(3):
738 759 color = jwin_pal[jcCURSORLIGHT];
739 759 break;
740 case dvc(5):
741 594 color = jwin_pal[jcCURSORDARK];
742 594 break;
743 default:
744 5742 continue;
745 }
746 2706 putpixel(bmp, x, y, color);
747 2706 }
748 528 }
749 33 }
750 33 void load_mouse()
751 {
752 33 system_pal();
753 33 MouseSprite::set(-1);
754 33 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
755 33 int32_t sz = 16*scale;
756
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 for(int32_t j = 0; j < 1; ++j)
757 {
758 33 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
759
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(zcmouse[j])
760 destroy_bitmap(zcmouse[j]);
761 33 zcmouse[j] = create_bitmap_ex(8,sz,sz);
762 33 clear_bitmap(zcmouse[j]);
763 33 clear_bitmap(tmpbmp);
764 33 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
765 33 recolor_mouse(tmpbmp);
766
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(sz!=16)
767 33 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
768 else
769 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
770 33 destroy_bitmap(tmpbmp);
771 33 }
772 33 zc_set_palette(*hw_palette);
773
774 33 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
775 33 clear_bitmap(blankmouse);
776
777 33 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
778 33 MouseSprite::assign(ZCM_BLANK, blankmouse);
779 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
780
781 //Reload the mouse
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(system_mouse)
783 sys_mouse();
784 33 else game_mouse();
785
786 33 destroy_bitmap(blankmouse);
787 33 game_pal();
788 33 }
789
790 // sets the video mode and initializes the palette and mouse sprite
791 33 bool game_vid_mode(int32_t mode,int32_t wait)
792 {
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
794 {
795 return false;
796 }
797
798 33 scrx = (resx-320)>>1;
799 33 scry = (resy-240)>>1;
800
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
801 33 zcmouse[q] = NULL;
802 33 load_mouse();
803
804
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 33 times.
561 for(int32_t i=240; i<256; i++)
805 528 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
806
807 33 zc_set_palette(RAMpal);
808 33 clear_to_color(screen,BLACK);
809
810 33 rest(wait);
811 33 return true;
812 33 }
813
814 7 void null_quest()
815 {
816 char qstdat_string[2048];
817 7 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
818 7 strcat(qstdat_string,"#NESQST_NEW_QST");
819
820 #ifdef __EMSCRIPTEN__
821 // The quest template data file is not included because it's really big and isn't really needed
822 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
823 // which is much smaller.
824 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
825 #endif
826
827 7 byte skip_flags[4] = { 0 };
828
829 7 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
830 7 }
831
832 7 void init_NES_mode()
833 {
834 /*
835 // qst.dat may not load correctly without this...
836 QHeader.templatepath[0]='\0';
837
838 if(!init_colordata(true, &QHeader, &QMisc))
839 {
840 return;
841 }
842
843 loadfullpal();
844 init_tiles(false, &QHeader);
845 */
846 7 null_quest();
847 7 }
848
849 //----------------------------------------------------------------
850
851 qword trianglelines[16]=
852 {
853 0x0000000000000000ULL,
854 0xFD00000000000000ULL,
855 0xFDFD000000000000ULL,
856 0xFDFDFD0000000000ULL,
857 0xFDFDFDFD00000000ULL,
858 0xFDFDFDFDFD000000ULL,
859 0xFDFDFDFDFDFD0000ULL,
860 0xFDFDFDFDFDFDFD00ULL,
861 0xFDFDFDFDFDFDFDFDULL,
862 0x00FDFDFDFDFDFDFDULL,
863 0x0000FDFDFDFDFDFDULL,
864 0x000000FDFDFDFDFDULL,
865 0x00000000FDFDFDFDULL,
866 0x0000000000FDFDFDULL,
867 0x000000000000FDFDULL,
868 0x00000000000000FDULL,
869 };
870
871 word screen_triangles[28][32];
872 /*
873 qword triangles[4][16]= //[direction][value]
874 {
875 {
876 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
877 },
878 {
879 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
880 },
881 {
882 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
883 },
884 {
885 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
886 }
887 };
888 */
889
890
891 /*
892 byte triangles[4][16][8]= //[direction][value][line]
893 {
894 {
895 {
896 0, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 1, 0, 0, 0, 0, 0, 0, 0
900 },
901 {
902 2, 1, 0, 0, 0, 0, 0, 0
903 },
904 {
905 3, 2, 1, 0, 0, 0, 0, 0
906 },
907 {
908 4, 3, 2, 1, 0, 0, 0, 0
909 },
910 {
911 5, 4, 3, 2, 1, 0, 0, 0
912 },
913 {
914 6, 5, 4, 3, 2, 1, 0, 0
915 },
916 {
917 7, 6, 5, 4, 3, 2, 1, 0
918 },
919 {
920 8, 7, 6, 5, 4, 3, 2, 1
921 },
922 {
923 8, 8, 7, 6, 5, 4, 3, 2
924 },
925 {
926 8, 8, 8, 7, 6, 5, 4, 3
927 },
928 {
929 8, 8, 8, 8, 7, 6, 5, 4
930 },
931 {
932 8, 8, 8, 8, 8, 7, 6, 5
933 },
934 {
935 8, 8, 8, 8, 8, 8, 7, 6
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 7
939 },
940 {
941 8, 8, 8, 8, 8, 8, 8, 8
942 }
943 },
944 {
945 {
946 0, 0, 0, 0, 0, 0, 0, 0
947 },
948 {
949 15, 0, 0, 0, 0, 0, 0, 0
950 },
951 {
952 14, 15, 0, 0, 0, 0, 0, 0
953 },
954 {
955 13, 14, 15, 0, 0, 0, 0, 0
956 },
957 {
958 12, 13, 14, 15, 0, 0, 0, 0
959 },
960 {
961 11, 12, 13, 14, 15, 0, 0, 0
962 },
963 {
964 10, 11, 12, 13, 14, 15, 0, 0
965 },
966 {
967 9, 10, 11, 12, 13, 14, 15, 0
968 },
969 {
970 8, 9, 10, 11, 12, 13, 14, 15
971 },
972 {
973 8, 8, 9, 10, 11, 12, 13, 14
974 },
975 {
976 8, 8, 8, 9, 10, 11, 12, 13
977 },
978 {
979 8, 8, 8, 8, 9, 10, 11, 12
980 },
981 {
982 8, 8, 8, 8, 8, 9, 10, 11
983 },
984 {
985 8, 8, 8, 8, 8, 8, 9, 10
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 9
989 },
990 {
991 8, 8, 8, 8, 8, 8, 8, 8
992 }
993 },
994 {
995 {
996 0, 0, 0, 0, 0, 0, 0, 0
997 },
998 {
999 0, 0, 0, 0, 0, 0, 0, 1
1000 },
1001 {
1002 0, 0, 0, 0, 0, 0, 1, 2
1003 },
1004 {
1005 0, 0, 0, 0, 0, 1, 2, 3
1006 },
1007 {
1008 0, 0, 0, 0, 1, 2, 3, 4
1009 },
1010 {
1011 0, 0, 0, 1, 2, 3, 4, 5
1012 },
1013 {
1014 0, 0, 1, 2, 3, 4, 5, 6
1015 },
1016 {
1017 0, 1, 2, 3, 4, 5, 6, 7
1018 },
1019 {
1020 1, 2, 3, 4, 5, 6, 7, 8
1021 },
1022 {
1023 2, 3, 4, 5, 6, 7, 8, 8
1024 },
1025 {
1026 3, 4, 5, 6, 7, 8, 8, 8
1027 },
1028 {
1029 4, 5, 6, 7, 8, 8, 8, 8
1030 },
1031 {
1032 5, 6, 7, 8, 8, 8, 8, 8
1033 },
1034 {
1035 6, 7, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 7, 8, 8, 8, 8, 8, 8, 8
1039 },
1040 {
1041 8, 8, 8, 8, 8, 8, 8, 8
1042 }
1043 },
1044 {
1045 {
1046 0, 0, 0, 0, 0, 0, 0, 0
1047 },
1048 {
1049 0, 0, 0, 0, 0, 0, 0, 15
1050 },
1051 {
1052 0, 0, 0, 0, 0, 0, 15, 14
1053 },
1054 {
1055 0, 0, 0, 0, 0, 15, 14, 13
1056 },
1057 {
1058 0, 0, 0, 0, 15, 14, 13, 12
1059 },
1060 {
1061 0, 0, 0, 15, 14, 13, 12, 11
1062 },
1063 {
1064 0, 0, 15, 14, 13, 12, 11, 10
1065 },
1066 {
1067 0, 15, 14, 13, 12, 11, 10, 9
1068 },
1069 {
1070 15, 14, 13, 12, 11, 10, 9, 8
1071 },
1072 {
1073 14, 13, 12, 11, 10, 9, 8, 8
1074 },
1075 {
1076 13, 12, 11, 10, 9, 8, 8, 8
1077 },
1078 {
1079 12, 11, 10, 9, 8, 8, 8, 8
1080 },
1081 {
1082 11, 10, 9, 8, 8, 8, 8, 8
1083 },
1084 {
1085 10, 9, 8, 8, 8, 8, 8, 8
1086 },
1087 {
1088 9, 8, 8, 8, 8, 8, 8, 8
1089 },
1090 {
1091 8, 8, 8, 8, 8, 8, 8, 8
1092 }
1093 }
1094 };
1095 */
1096
1097
1098
1099 /*
1100 for (int32_t blockrow=0; blockrow<30; ++i)
1101 {
1102 for (int32_t linerow=0; linerow<8; ++i)
1103 {
1104 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1105 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1106 {
1107 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1108 ++triangleline;
1109 }
1110 }
1111 }
1112 */
1113
1114 // the ULL suffixes are to prevent this warning:
1115 // warning: integer constant is too large for "int32_t" type
1116
1117 qword triangles[4][16][8]= //[direction][value][line]
1118 {
1119 {
1120 {
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL,
1128 0x0000000000000000ULL
1129 },
1130 {
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL,
1138 0x0000000000000000ULL
1139 },
1140 {
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL
1149 },
1150 {
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL
1159 },
1160 {
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL,
1164 0xFD00000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL
1169 },
1170 {
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL,
1174 0xFDFD000000000000ULL,
1175 0xFD00000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL
1179 },
1180 {
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL,
1184 0xFDFDFD0000000000ULL,
1185 0xFDFD000000000000ULL,
1186 0xFD00000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL
1189 },
1190 {
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL,
1194 0xFDFDFDFD00000000ULL,
1195 0xFDFDFD0000000000ULL,
1196 0xFDFD000000000000ULL,
1197 0xFD00000000000000ULL,
1198 0x0000000000000000ULL
1199 },
1200 {
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL,
1204 0xFDFDFDFDFD000000ULL,
1205 0xFDFDFDFD00000000ULL,
1206 0xFDFDFD0000000000ULL,
1207 0xFDFD000000000000ULL,
1208 0xFD00000000000000ULL
1209 },
1210 {
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL,
1214 0xFDFDFDFDFDFD0000ULL,
1215 0xFDFDFDFDFD000000ULL,
1216 0xFDFDFDFD00000000ULL,
1217 0xFDFDFD0000000000ULL,
1218 0xFDFD000000000000ULL
1219 },
1220 {
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFD00ULL,
1225 0xFDFDFDFDFDFD0000ULL,
1226 0xFDFDFDFDFD000000ULL,
1227 0xFDFDFDFD00000000ULL,
1228 0xFDFDFD0000000000ULL
1229 },
1230 {
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFD00ULL,
1236 0xFDFDFDFDFDFD0000ULL,
1237 0xFDFDFDFDFD000000ULL,
1238 0xFDFDFDFD00000000ULL
1239 },
1240 {
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFD00ULL,
1247 0xFDFDFDFDFDFD0000ULL,
1248 0xFDFDFDFDFD000000ULL
1249 },
1250 {
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFD00ULL,
1258 0xFDFDFDFDFDFD0000ULL
1259 },
1260 {
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0xFDFDFDFDFDFDFD00ULL
1269 },
1270 {
1271 0xFDFDFDFDFDFDFDFDULL,
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL
1279 }
1280 },
1281 {
1282 {
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL,
1290 0x0000000000000000ULL
1291 },
1292 {
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL,
1300 0x0000000000000000ULL
1301 },
1302 {
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL
1311 },
1312 {
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL
1321 },
1322 {
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL,
1326 0x00000000000000FDULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL
1331 },
1332 {
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL,
1336 0x000000000000FDFDULL,
1337 0x00000000000000FDULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0x0000000000000000ULL
1341 },
1342 {
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL,
1346 0x0000000000FDFDFDULL,
1347 0x000000000000FDFDULL,
1348 0x00000000000000FDULL,
1349 0x0000000000000000ULL,
1350 0x0000000000000000ULL
1351 },
1352 {
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL,
1356 0x00000000FDFDFDFDULL,
1357 0x0000000000FDFDFDULL,
1358 0x000000000000FDFDULL,
1359 0x00000000000000FDULL,
1360 0x0000000000000000ULL
1361 },
1362 {
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL,
1366 0x000000FDFDFDFDFDULL,
1367 0x00000000FDFDFDFDULL,
1368 0x0000000000FDFDFDULL,
1369 0x000000000000FDFDULL,
1370 0x00000000000000FDULL
1371 },
1372 {
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL,
1376 0x0000FDFDFDFDFDFDULL,
1377 0x000000FDFDFDFDFDULL,
1378 0x00000000FDFDFDFDULL,
1379 0x0000000000FDFDFDULL,
1380 0x000000000000FDFDULL
1381 },
1382 {
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0x00FDFDFDFDFDFDFDULL,
1387 0x0000FDFDFDFDFDFDULL,
1388 0x000000FDFDFDFDFDULL,
1389 0x00000000FDFDFDFDULL,
1390 0x0000000000FDFDFDULL
1391 },
1392 {
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0x00FDFDFDFDFDFDFDULL,
1398 0x0000FDFDFDFDFDFDULL,
1399 0x000000FDFDFDFDFDULL,
1400 0x00000000FDFDFDFDULL
1401 },
1402 {
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0x00FDFDFDFDFDFDFDULL,
1409 0x0000FDFDFDFDFDFDULL,
1410 0x000000FDFDFDFDFDULL
1411 },
1412 {
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL,
1419 0x00FDFDFDFDFDFDFDULL,
1420 0x0000FDFDFDFDFDFDULL
1421 },
1422 {
1423 0xFDFDFDFDFDFDFDFDULL,
1424 0xFDFDFDFDFDFDFDFDULL,
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0x00FDFDFDFDFDFDFDULL
1431 },
1432 {
1433 0xFDFDFDFDFDFDFDFDULL,
1434 0xFDFDFDFDFDFDFDFDULL,
1435 0xFDFDFDFDFDFDFDFDULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL
1441 }
1442 },
1443 {
1444 {
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL
1453 },
1454 {
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0x0000000000000000ULL,
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0xFD00000000000000ULL
1463 },
1464 {
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0xFD00000000000000ULL,
1472 0xFDFD000000000000ULL
1473 },
1474 {
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0xFD00000000000000ULL,
1481 0xFDFD000000000000ULL,
1482 0xFDFDFD0000000000ULL
1483 },
1484 {
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0xFD00000000000000ULL,
1490 0xFDFD000000000000ULL,
1491 0xFDFDFD0000000000ULL,
1492 0xFDFDFDFD00000000ULL
1493 },
1494 {
1495 0x0000000000000000ULL,
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0xFD00000000000000ULL,
1499 0xFDFD000000000000ULL,
1500 0xFDFDFD0000000000ULL,
1501 0xFDFDFDFD00000000ULL,
1502 0xFDFDFDFDFD000000ULL
1503 },
1504 {
1505 0x0000000000000000ULL,
1506 0x0000000000000000ULL,
1507 0xFD00000000000000ULL,
1508 0xFDFD000000000000ULL,
1509 0xFDFDFD0000000000ULL,
1510 0xFDFDFDFD00000000ULL,
1511 0xFDFDFDFDFD000000ULL,
1512 0xFDFDFDFDFDFD0000ULL
1513 },
1514 {
1515 0x0000000000000000ULL,
1516 0xFD00000000000000ULL,
1517 0xFDFD000000000000ULL,
1518 0xFDFDFD0000000000ULL,
1519 0xFDFDFDFD00000000ULL,
1520 0xFDFDFDFDFD000000ULL,
1521 0xFDFDFDFDFDFD0000ULL,
1522 0xFDFDFDFDFDFDFD00ULL
1523 },
1524 {
1525 0xFD00000000000000ULL,
1526 0xFDFD000000000000ULL,
1527 0xFDFDFD0000000000ULL,
1528 0xFDFDFDFD00000000ULL,
1529 0xFDFDFDFDFD000000ULL,
1530 0xFDFDFDFDFDFD0000ULL,
1531 0xFDFDFDFDFDFDFD00ULL,
1532 0xFDFDFDFDFDFDFDFDULL
1533 },
1534 {
1535 0xFDFD000000000000ULL,
1536 0xFDFDFD0000000000ULL,
1537 0xFDFDFDFD00000000ULL,
1538 0xFDFDFDFDFD000000ULL,
1539 0xFDFDFDFDFDFD0000ULL,
1540 0xFDFDFDFDFDFDFD00ULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL
1543 },
1544 {
1545 0xFDFDFD0000000000ULL,
1546 0xFDFDFDFD00000000ULL,
1547 0xFDFDFDFDFD000000ULL,
1548 0xFDFDFDFDFDFD0000ULL,
1549 0xFDFDFDFDFDFDFD00ULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL,
1552 0xFDFDFDFDFDFDFDFDULL
1553 },
1554 {
1555 0xFDFDFDFD00000000ULL,
1556 0xFDFDFDFDFD000000ULL,
1557 0xFDFDFDFDFDFD0000ULL,
1558 0xFDFDFDFDFDFDFD00ULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL
1563 },
1564 {
1565 0xFDFDFDFDFD000000ULL,
1566 0xFDFDFDFDFDFD0000ULL,
1567 0xFDFDFDFDFDFDFD00ULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL
1573 },
1574 {
1575 0xFDFDFDFDFDFD0000ULL,
1576 0xFDFDFDFDFDFDFD00ULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL
1583 },
1584 {
1585 0xFDFDFDFDFDFDFD00ULL,
1586 0xFDFDFDFDFDFDFDFDULL,
1587 0xFDFDFDFDFDFDFDFDULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL
1593 },
1594 {
1595 0xFDFDFDFDFDFDFDFDULL,
1596 0xFDFDFDFDFDFDFDFDULL,
1597 0xFDFDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL
1603 }
1604 },
1605 {
1606 {
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL
1615 },
1616 {
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x0000000000000000ULL,
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x00000000000000FDULL
1625 },
1626 {
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x0000000000000000ULL,
1630 0x0000000000000000ULL,
1631 0x0000000000000000ULL,
1632 0x0000000000000000ULL,
1633 0x00000000000000FDULL,
1634 0x000000000000FDFDULL
1635 },
1636 {
1637 0x0000000000000000ULL,
1638 0x0000000000000000ULL,
1639 0x0000000000000000ULL,
1640 0x0000000000000000ULL,
1641 0x0000000000000000ULL,
1642 0x00000000000000FDULL,
1643 0x000000000000FDFDULL,
1644 0x0000000000FDFDFDULL
1645 },
1646 {
1647 0x0000000000000000ULL,
1648 0x0000000000000000ULL,
1649 0x0000000000000000ULL,
1650 0x0000000000000000ULL,
1651 0x00000000000000FDULL,
1652 0x000000000000FDFDULL,
1653 0x0000000000FDFDFDULL,
1654 0x00000000FDFDFDFDULL
1655 },
1656 {
1657 0x0000000000000000ULL,
1658 0x0000000000000000ULL,
1659 0x0000000000000000ULL,
1660 0x00000000000000FDULL,
1661 0x000000000000FDFDULL,
1662 0x0000000000FDFDFDULL,
1663 0x00000000FDFDFDFDULL,
1664 0x000000FDFDFDFDFDULL
1665 },
1666 {
1667 0x0000000000000000ULL,
1668 0x0000000000000000ULL,
1669 0x00000000000000FDULL,
1670 0x000000000000FDFDULL,
1671 0x0000000000FDFDFDULL,
1672 0x00000000FDFDFDFDULL,
1673 0x000000FDFDFDFDFDULL,
1674 0x0000FDFDFDFDFDFDULL
1675 },
1676 {
1677 0x0000000000000000ULL,
1678 0x00000000000000FDULL,
1679 0x000000000000FDFDULL,
1680 0x0000000000FDFDFDULL,
1681 0x00000000FDFDFDFDULL,
1682 0x000000FDFDFDFDFDULL,
1683 0x0000FDFDFDFDFDFDULL,
1684 0x00FDFDFDFDFDFDFDULL
1685 },
1686 {
1687 0x00000000000000FDULL,
1688 0x000000000000FDFDULL,
1689 0x0000000000FDFDFDULL,
1690 0x00000000FDFDFDFDULL,
1691 0x000000FDFDFDFDFDULL,
1692 0x0000FDFDFDFDFDFDULL,
1693 0x00FDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL
1695 },
1696 {
1697 0x000000000000FDFDULL,
1698 0x0000000000FDFDFDULL,
1699 0x00000000FDFDFDFDULL,
1700 0x000000FDFDFDFDFDULL,
1701 0x0000FDFDFDFDFDFDULL,
1702 0x00FDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL
1705 },
1706 {
1707 0x0000000000FDFDFDULL,
1708 0x00000000FDFDFDFDULL,
1709 0x000000FDFDFDFDFDULL,
1710 0x0000FDFDFDFDFDFDULL,
1711 0x00FDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL
1715 },
1716 {
1717 0x00000000FDFDFDFDULL,
1718 0x000000FDFDFDFDFDULL,
1719 0x0000FDFDFDFDFDFDULL,
1720 0x00FDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL
1725 },
1726 {
1727 0x000000FDFDFDFDFDULL,
1728 0x0000FDFDFDFDFDFDULL,
1729 0x00FDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL
1735 },
1736 {
1737 0x0000FDFDFDFDFDFDULL,
1738 0x00FDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL,
1743 0xFDFDFDFDFDFDFDFDULL,
1744 0xFDFDFDFDFDFDFDFDULL
1745 },
1746 {
1747 0x00FDFDFDFDFDFDFDULL,
1748 0xFDFDFDFDFDFDFDFDULL,
1749 0xFDFDFDFDFDFDFDFDULL,
1750 0xFDFDFDFDFDFDFDFDULL,
1751 0xFDFDFDFDFDFDFDFDULL,
1752 0xFDFDFDFDFDFDFDFDULL,
1753 0xFDFDFDFDFDFDFDFDULL,
1754 0xFDFDFDFDFDFDFDFDULL
1755 },
1756 {
1757 0xFDFDFDFDFDFDFDFDULL,
1758 0xFDFDFDFDFDFDFDFDULL,
1759 0xFDFDFDFDFDFDFDFDULL,
1760 0xFDFDFDFDFDFDFDFDULL,
1761 0xFDFDFDFDFDFDFDFDULL,
1762 0xFDFDFDFDFDFDFDFDULL,
1763 0xFDFDFDFDFDFDFDFDULL,
1764 0xFDFDFDFDFDFDFDFDULL
1765 }
1766 }
1767 };
1768
1769 int32_t black_opening_count=0;
1770 int32_t black_opening_x,black_opening_y;
1771 int32_t black_opening_shape;
1772
1773 1134 int32_t choose_opening_shape()
1774 {
1775 // First, count how many bits are set
1776 1134 int32_t numBits=0;
1777 int32_t bitCounter;
1778
1779
2/2
✓ Branch 0 taken 5670 times.
✓ Branch 1 taken 1134 times.
6804 for(int32_t i=0; i<bosMAX; i++)
1780 {
1781
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1350 times.
5670 if(COOLSCROLL&(1<<i))
1782 1350 numBits++;
1783 5670 }
1784
1785 // Shouldn't happen...
1786
1/2
✓ Branch 0 taken 1134 times.
✗ Branch 1 not taken.
1134 if(numBits==0)
1787 return bosCIRCLE;
1788
1789 // Pick a bit
1790 1134 bitCounter=zc_rand()%numBits+1;
1791
1792
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 26 times.
1426 for(int32_t i=0; i<bosMAX; i++)
1793 {
1794 // If this bit is set, decrement the bit counter
1795
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1264 times.
1400 if(COOLSCROLL&(1<<i))
1796 1264 bitCounter--;
1797
1798 // When the counter hits 0, return a value based on
1799 // which bit it stopped on.
1800 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1801
2/2
✓ Branch 0 taken 1108 times.
✓ Branch 1 taken 292 times.
1400 if(bitCounter==0)
1802 1108 return i;
1803 292 }
1804
1805 // Shouldn't be necessary, but the compiler might complain, at least
1806 26 return bosCIRCLE;
1807 1134 }
1808
1809 312 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1810 {
1811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
312 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1812
1813 312 int32_t w=256, h=224;
1814 312 int32_t blockrows=28, blockcolumns=32;
1815 312 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1816
1817
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 312 times.
9048 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1818 {
1819
2/2
✓ Branch 0 taken 279552 times.
✓ Branch 1 taken 8736 times.
288288 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1820 {
1821
2/2
✓ Branch 0 taken 148819 times.
✓ Branch 1 taken 130733 times.
279552 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1822 279552 }
1823 8736 }
1824
1825 312 black_opening_count = 66;
1826 312 black_opening_x = x;
1827 312 black_opening_y = y;
1828 312 lensclk = 0;
1829 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1830
1831
1832
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(black_opening_shape == bosFADEBLACK)
1833 {
1834 refreshTints();
1835 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1836 }
1837
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(wait)
1838 {
1839 FFCore.warpScriptCheck();
1840 for(int32_t i=0; i<66; i++)
1841 {
1842 draw_screen(tmpscr);
1843 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1844 advanceframe(true);
1845
1846 if(Quit)
1847 {
1848 break;
1849 }
1850 }
1851 }
1852 312 }
1853
1854 822 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1855 {
1856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 822 times.
822 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1857
1858 822 int32_t w=256, h=224;
1859 822 int32_t blockrows=28, blockcolumns=32;
1860 822 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1861
1862
2/2
✓ Branch 0 taken 23016 times.
✓ Branch 1 taken 822 times.
23838 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1863 {
1864
2/2
✓ Branch 0 taken 736512 times.
✓ Branch 1 taken 23016 times.
759528 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1865 {
1866
2/2
✓ Branch 0 taken 335267 times.
✓ Branch 1 taken 401245 times.
736512 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1867 736512 }
1868 23016 }
1869
1870 822 black_opening_count = -66;
1871 822 black_opening_x = x;
1872 822 black_opening_y = y;
1873 822 lensclk = 0;
1874
1/2
✓ Branch 0 taken 822 times.
✗ Branch 1 not taken.
822 if(black_opening_shape == bosFADEBLACK)
1875 {
1876 refreshTints();
1877 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1878 }
1879
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 627 times.
822 if(wait)
1880 {
1881 627 FFCore.warpScriptCheck();
1882
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 41382 times.
42009 for(int32_t i=0; i<66; i++)
1883 {
1884 41382 draw_screen(tmpscr);
1885 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1886 41382 advanceframe(true);
1887
1888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41382 times.
41382 if(Quit)
1889 {
1890 break;
1891 }
1892 41382 }
1893 627 }
1894 822 }
1895
1896 74844 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1897 {
1898 74844 clear_to_color(tmp_scr,BLACK);
1899 74844 int32_t w=256, h=224;
1900
1901
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70488 times.
74844 switch(black_opening_shape)
1902 {
1903 case bosOVAL:
1904 {
1905 858 double new_w=(w/2)+abs(w/2-x);
1906 858 double new_h=(h/2)+abs(h/2-y);
1907 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1908 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1909 858 break;
1910 }
1911
1912 case bosTRIANGLE:
1913 {
1914 660 double new_w=(w/2)+abs(w/2-x);
1915 660 double new_h=(h/2)+abs(h/2-y);
1916 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1917 660 double P2= (PI/2);
1918 660 double P23=(2*PI/3);
1919 660 double P43=(4*PI/3);
1920 660 double Pa= (-4*PI*a/(3*max_a));
1921 660 double angle=P2+Pa;
1922 660 double a0=angle;
1923 660 double a2=angle+P23;
1924 660 double a4=angle+P43;
1925 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1926 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1927 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1928 0);
1929 660 break;
1930 }
1931
1932 case bosSMAS:
1933 {
1934
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1935
1936
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1937 {
1938
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1939 {
1940 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1941
1942
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1943 {
1944 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1945
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1946 20342784 [linerow];
1947 20342784 ++triangleline;
1948
1949
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1950 {
1951 2542848 }
1952 20342784 }
1953 635712 }
1954 79464 }
1955
1956 2838 break;
1957 }
1958
1959 case bosFADEBLACK:
1960 {
1961 if(black_opening_count<0)
1962 {
1963 black_fade(zc_min(-black_opening_count,63));
1964 }
1965 else if(black_opening_count>0)
1966 {
1967 black_fade(63-zc_max(black_opening_count-3,0));
1968 }
1969 else black_fade(0);
1970 return; //no blitting from tmp_scr!
1971 }
1972
1973 70488 case bosCIRCLE:
1974 default:
1975 {
1976 70488 double new_w=(w/2)+abs(w/2-x);
1977 70488 double new_h=(h/2)+abs(h/2-y);
1978 70488 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1979 //circlefill(tmp_scr,x,y,a<<3,0);
1980 70488 circlefill(tmp_scr,x,y,r,0);
1981 70488 break;
1982 }
1983 }
1984
1985 74844 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1986 74844 }
1987
1988
1989 void black_fade(int32_t fadeamnt)
1990 {
1991 for(int32_t i=0; i < 0xEF; i++)
1992 {
1993 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1994 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1995 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1996 }
1997
1998 refreshpal = true;
1999 }
2000
2001 //----------------------------------------------------------------
2002
2003 32885089 bool item_disabled(int32_t item) //is this item disabled?
2004 {
2005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32885089 times.
32885089 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
2006 }
2007
2008 6715675 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
2009 {
2010
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6635258 times.
6715675 if(current_item(item_type, true) >=item)
2011 {
2012 80417 return true;
2013 }
2014
2015 6635258 return false;
2016 6715675 }
2017
2018 27682319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
2019 {
2020
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075885 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14716964 times.
✓ Branch 7 taken 4802881 times.
✓ Branch 8 taken 34672 times.
27682319 switch(item_type)
2021 {
2022 case itype_bomb:
2023 case itype_sbomb:
2024 {
2025 int32_t itemid = getItemID(itemsbuf, item_type, it);
2026
2027 if(itemid == -1)
2028 return false;
2029
2030 return (game->get_item(itemid));
2031 }
2032
2033 case itype_clock:
2034 {
2035 5075885 int32_t itemid = getItemID(itemsbuf, item_type, it);
2036
2037
2/4
✓ Branch 0 taken 5075885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075885 times.
✗ Branch 3 not taken.
5075885 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2038 return (game->get_item(itemid));
2039 5075885 return Hero.getClock()?1:0;
2040 }
2041
2042 case itype_key:
2043 return (game->get_keys()>0);
2044
2045 case itype_magiccontainer:
2046 return (game->get_maxmagic()>=game->get_mp_per_block());
2047
2048 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2049 {
2050
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2051 {
2052 case -2:
2053 {
2054 for(int32_t i=0; i<MAXLEVELS; i++)
2055 {
2056 if(game->lvlitems[i]&liTRIFORCE)
2057 {
2058 return true;
2059 }
2060 }
2061
2062 return false;
2063 }
2064
2065 case -1:
2066 return (game->lvlitems[dlevel]&liTRIFORCE);
2067
2068 default:
2069
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2070 {
2071 3051917 return (game->lvlitems[it]&liTRIFORCE);
2072 }
2073
2074 break;
2075 }
2076
2077 return 0;
2078 }
2079
2080 case itype_map: //it: -2=any, -1=current level, other=that level
2081 {
2082
1/3
✓ Branch 0 taken 14716964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14716964 switch(it)
2083 {
2084 case -2:
2085 {
2086 for(int32_t i=0; i<MAXLEVELS; i++)
2087 {
2088 if(game->lvlitems[i]&liMAP)
2089 {
2090 return true;
2091 }
2092 }
2093
2094 return false;
2095 }
2096
2097 case -1:
2098 return (game->lvlitems[dlevel]&liMAP)!=0;
2099
2100 default:
2101
2/4
✓ Branch 0 taken 14716964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14716964 times.
14716964 if(it>=0&&it<MAXLEVELS)
2102 {
2103 14716964 return (game->lvlitems[it]&liMAP)!=0;
2104 }
2105
2106 break;
2107 }
2108
2109 return 0;
2110 }
2111
2112 case itype_compass: //it: -2=any, -1=current level, other=that level
2113 {
2114
1/3
✓ Branch 0 taken 4802881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4802881 switch(it)
2115 {
2116 case -2:
2117 {
2118 for(int32_t i=0; i<MAXLEVELS; i++)
2119 {
2120 if(game->lvlitems[i]&liCOMPASS)
2121 {
2122 return true;
2123 }
2124 }
2125
2126 return false;
2127 }
2128
2129 case -1:
2130 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2131
2132 default:
2133
2/4
✓ Branch 0 taken 4802881 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4802881 times.
✗ Branch 3 not taken.
4802881 if(it>=0&&it<MAXLEVELS)
2134 {
2135 4802881 return (game->lvlitems[it]&liCOMPASS)!=0;
2136 }
2137
2138 break;
2139 }
2140 return 0;
2141 }
2142
2143 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2144 {
2145
1/3
✓ Branch 0 taken 34672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34672 switch(it)
2146 {
2147 case -2:
2148 {
2149 for(int32_t i=0; i<MAXLEVELS; i++)
2150 {
2151 if(game->lvlitems[i]&liBOSSKEY)
2152 {
2153 return true;
2154 }
2155 }
2156
2157 return false;
2158 }
2159
2160 case -1:
2161 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2162
2163 default:
2164
2/4
✓ Branch 0 taken 34672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34672 times.
34672 if(it>=0&&it<MAXLEVELS)
2165 {
2166 34672 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2167 }
2168 break;
2169 }
2170 return 0;
2171 }
2172
2173 default:
2174 //it=(1<<(it-1));
2175 /*if (item_type>=itype_max)
2176 {
2177 system_pal();
2178 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2179 game_pal();
2180
2181 return false;
2182 }*/
2183 int32_t itemid = getItemID(itemsbuf, item_type, it);
2184
2185 if(itemid == -1)
2186 return false;
2187
2188 return game->get_item(itemid);
2189 }
2190 27682319 }
2191
2192
2193 86609834 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2194 {
2195
9/9
✓ Branch 0 taken 5075885 times.
✓ Branch 1 taken 46002754 times.
✓ Branch 2 taken 5075885 times.
✓ Branch 3 taken 5075885 times.
✓ Branch 4 taken 5075885 times.
✓ Branch 5 taken 5075885 times.
✓ Branch 6 taken 5075885 times.
✓ Branch 7 taken 5075885 times.
✓ Branch 8 taken 5075885 times.
86609834 switch(item_type)
2196 {
2197 case itype_clock:
2198 {
2199 5075885 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2200
2201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5075885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5075885 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2202 return itemsbuf[maxid].fam_type;
2203
2204 5075885 return has_item(itype_clock,1) ? 1 : 0;
2205 }
2206
2207 case itype_key:
2208 5075885 return game->get_keys();
2209
2210 case itype_lkey:
2211 5075885 return game->lvlkeys[get_dlevel()];
2212
2213 case itype_magiccontainer:
2214 5075885 return game->get_maxmagic()/game->get_mp_per_block();
2215
2216 case itype_triforcepiece:
2217 {
2218 5075885 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 2598853120 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2223 2598853120 }
2224
2225 5075885 return count;
2226 }
2227
2228 case itype_map:
2229 {
2230 5075885 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 2598853120 count+=(game->lvlitems[i]&liMAP)?1:0;
2235 2598853120 }
2236
2237 5075885 return count;
2238 }
2239
2240 case itype_compass:
2241 {
2242 5075885 int32_t count=0;
2243
2244
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2245 {
2246 2598853120 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2247 2598853120 }
2248
2249 5075885 return count;
2250 }
2251
2252 case itype_bosskey:
2253 {
2254 5075885 int32_t count=0;
2255
2256
2/2
✓ Branch 0 taken 2598853120 times.
✓ Branch 1 taken 5075885 times.
2603929005 for(int32_t i=0; i<MAXLEVELS; i++)
2257 {
2258 2598853120 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2259 2598853120 }
2260
2261 5075885 return count;
2262 }
2263
2264 default:
2265 46002754 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2266
2267
2/2
✓ Branch 0 taken 8708246 times.
✓ Branch 1 taken 37294508 times.
46002754 if(maxid == -1)
2268 37294508 return 0;
2269
2270 8708246 return itemsbuf[maxid].fam_type;
2271 }
2272 86609834 }
2273
2274 79894159 int32_t current_item(int32_t item_type) //item currently being used
2275 {
2276 79894159 return current_item(item_type, true);
2277 }
2278
2279 33 std::map<int32_t, int32_t> itemcache;
2280
2281 // Not actually used by anything at the moment...
2282 void removeFromItemCache(int32_t itemclass)
2283 {
2284 itemcache.erase(itemclass);
2285 }
2286
2287 24261 void flushItemCache()
2288 {
2289 24261 itemcache.clear();
2290
2291 //also fix the active subscreen if items were deleted -DD
2292
1/2
✓ Branch 0 taken 24261 times.
✗ Branch 1 not taken.
24261 if(game != NULL)
2293 {
2294 24261 verifyBothWeapons();
2295 24261 load_Sitems(&QMisc);
2296 24261 }
2297 24261 }
2298
2299 // This is used often, so it should be as direct as possible.
2300 2829168445 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2301 {
2302
2/2
✓ Branch 0 taken 2770715320 times.
✓ Branch 1 taken 58453125 times.
2829168445 if(jinx_check)
2303 {
2304
4/4
✓ Branch 0 taken 38291923 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34628259 times.
✓ Branch 3 taken 3663664 times.
58453125 if(!(HeroSwordClk() || HeroItemClk()))
2305 34628259 jinx_check = false; //not jinxed
2306 58453125 }
2307
4/4
✓ Branch 0 taken 2804947534 times.
✓ Branch 1 taken 24220911 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2781297171 times.
2829168445 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2308 {
2309 2781297171 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2310
2311
2/2
✓ Branch 0 taken 2768911095 times.
✓ Branch 1 taken 12386076 times.
2781297171 if(res != itemcache.end())
2312 2768911095 return res->second;
2313 12386076 }
2314
2315 60257350 int32_t result = -1;
2316 60257350 int32_t highestlevel = -1;
2317
2318
2/2
✓ Branch 0 taken 15425881600 times.
✓ Branch 1 taken 60257350 times.
15486138950 for(int32_t i=0; i<MAXITEMS; i++)
2319 {
2320
5/6
✓ Branch 0 taken 1197955310 times.
✓ Branch 1 taken 14227926290 times.
✓ Branch 2 taken 17819159 times.
✓ Branch 3 taken 1180136151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819159 times.
15425881600 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2321 {
2322
4/4
✓ Branch 0 taken 5189638 times.
✓ Branch 1 taken 12629521 times.
✓ Branch 2 taken 1358181 times.
✓ Branch 3 taken 16460978 times.
17819159 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2323 {
2324 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2325
2/2
✓ Branch 0 taken 16460821 times.
✓ Branch 1 taken 157 times.
16460978 if(!checkmagiccost(i))
2326 {
2327
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 145 times.
157 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2328 12 }
2329 16460833 }
2330
6/6
✓ Branch 0 taken 15432428 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17819014 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2331 {
2332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2333 759329 continue;
2334 }
2335
2336
2/2
✓ Branch 0 taken 237660 times.
✓ Branch 1 taken 16822025 times.
17059685 if(itemsbuf[i].fam_type >= highestlevel)
2337 {
2338 16822025 highestlevel = itemsbuf[i].fam_type;
2339 16822025 result=i;
2340 16822025 }
2341 17059685 }
2342 15425122126 }
2343
2344
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36432484 times.
60257350 if(!jinx_check) //Can't cache jinx_check results
2345 36432484 itemcache[itemtype] = result;
2346 60257350 return result;
2347 2829168445 }
2348
2349 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2350 2805661025 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2351 {
2352 2805661025 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2353
2/2
✓ Branch 0 taken 34945705 times.
✓ Branch 1 taken 2770715320 times.
2805661025 if(!jinx_check) //If not already a jinx-immune-only check...
2354 {
2355 //And the player IS jinxed...
2356
4/4
✓ Branch 0 taken 2750819702 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2747207900 times.
2770715320 if(HeroSwordClk() || HeroItemClk())
2357 {
2358 //Then do a jinx-immune-only check here
2359 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2360 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2361 //Should NOT need a compat rule, as this should always return -1 in old quests.
2362
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2363 22404776 }
2364 2769612676 }
2365 2804558381 return ret;
2366 2805661025 }
2367 17662014 int32_t current_item_power(int32_t itemtype)
2368 {
2369 17662014 int32_t result = current_item_id(itemtype,true);
2370
2/2
✓ Branch 0 taken 13152285 times.
✓ Branch 1 taken 4509729 times.
17662014 return (result<0) ? 0 : itemsbuf[result].power;
2371 }
2372
2373 7 int32_t heart_container_id()
2374 {
2375
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2376 {
2377
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2378 {
2379 7 return i;
2380 }
2381 196 }
2382 return -1;
2383 7 }
2384
2385 5075885 int32_t item_tile_mod()
2386 {
2387 5075885 int32_t tile=0;
2388
2389
2/2
✓ Branch 0 taken 1064842 times.
✓ Branch 1 taken 4011043 times.
5075885 if(game->get_bombs())
2390 {
2391 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2392
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2393 3929984 tile+=itemsbuf[itemid].ltm;
2394 4011043 }
2395
2396
2/2
✓ Branch 0 taken 3905451 times.
✓ Branch 1 taken 1170434 times.
5075885 if(game->get_sbombs())
2397 {
2398 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2399
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2400 1169006 tile+=itemsbuf[itemid].ltm;
2401 1170434 }
2402
2403
2/2
✓ Branch 0 taken 4971942 times.
✓ Branch 1 taken 103943 times.
5075885 if(current_item(itype_clock))
2404 {
2405 103943 int32_t itemid =
2406
1/2
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
103943 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2407 ? iClock
2408 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2409
2/4
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103943 times.
103943 if(itemid > -1 && checkbunny(itemid))
2410 103943 tile+=itemsbuf[itemid].ltm;
2411 103943 }
2412
2413
2/2
✓ Branch 0 taken 4029973 times.
✓ Branch 1 taken 1045912 times.
5075885 if(current_item(itype_key))
2414 {
2415 1045912 int32_t itemid =
2416
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2417 ? iKey
2418 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2419
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2420 1045912 tile+=itemsbuf[itemid].ltm;
2421 1045912 }
2422
2423
2/2
✓ Branch 0 taken 4903354 times.
✓ Branch 1 taken 172531 times.
5075885 if(current_item(itype_lkey))
2424 {
2425 172531 int32_t itemid =
2426
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2427 ? iLevelKey
2428 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2429
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2430 172531 tile+=itemsbuf[itemid].ltm;
2431 172531 }
2432
2433
2/2
✓ Branch 0 taken 1040409 times.
✓ Branch 1 taken 4035476 times.
5075885 if(current_item(itype_map))
2434 {
2435 4035476 int32_t itemid =
2436
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2437 ? iMap
2438 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2439
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2440 4035476 tile+=itemsbuf[itemid].ltm;
2441 4035476 }
2442
2443
2/2
✓ Branch 0 taken 1018527 times.
✓ Branch 1 taken 4057358 times.
5075885 if(current_item(itype_compass))
2444 {
2445 4057358 int32_t itemid =
2446
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2447 ? iCompass
2448 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2449
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2450 4057358 tile+=itemsbuf[itemid].ltm;
2451 4057358 }
2452
2453
2/2
✓ Branch 0 taken 3206681 times.
✓ Branch 1 taken 1869204 times.
5075885 if(current_item(itype_bosskey))
2454 {
2455 1869204 int32_t itemid =
2456
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2457 ? iBossKey
2458 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2459
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2460 1869204 tile+=itemsbuf[itemid].ltm;
2461 1869204 }
2462
2463
2/2
✓ Branch 0 taken 2920770 times.
✓ Branch 1 taken 2155115 times.
5075885 if(current_item(itype_magiccontainer))
2464 {
2465 2155115 int32_t itemid =
2466
2/2
✓ Branch 0 taken 2062128 times.
✓ Branch 1 taken 92987 times.
2155115 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2467 ? iMagicC
2468 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2469
3/4
✓ Branch 0 taken 2155115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2153245 times.
2155115 if(itemid > -1 && checkbunny(itemid))
2470 2153245 tile+=itemsbuf[itemid].ltm;
2471 2155115 }
2472
2473
2/2
✓ Branch 0 taken 1376592 times.
✓ Branch 1 taken 3699293 times.
5075885 if(current_item(itype_triforcepiece))
2474 {
2475 3699293 int32_t itemid =
2476
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2477 ? iTriforce
2478 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2479
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2480 3699293 tile+=itemsbuf[itemid].ltm;
2481 3699293 }
2482
2483
2/2
✓ Branch 0 taken 5075885 times.
✓ Branch 1 taken 2598853120 times.
2603929005 for(int32_t i=0; i<itype_max; i++)
2484 {
2485
2/2
✓ Branch 0 taken 2540581376 times.
✓ Branch 1 taken 58271744 times.
2598853120 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2486 {
2487
2/2
✓ Branch 0 taken 1138120 times.
✓ Branch 1 taken 57133624 times.
58271744 switch(i)
2488 {
2489 case itype_bomb:
2490 case itype_sbomb:
2491 case itype_clock:
2492 case itype_key:
2493 case itype_lkey:
2494 case itype_map:
2495 case itype_compass:
2496 case itype_bosskey:
2497 case itype_magiccontainer:
2498 case itype_triforcepiece:
2499 1138120 continue; //already handled
2500 }
2501 57133624 }
2502 2597715000 int32_t itemid = current_item_id(i,false);
2503
2/2
✓ Branch 0 taken 2592639115 times.
✓ Branch 1 taken 5075885 times.
2597715000 if(i == itype_shield)
2504 5075885 itemid = getCurrentShield(false);
2505
2506
4/4
✓ Branch 0 taken 70934807 times.
✓ Branch 1 taken 2526780193 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70833826 times.
2597715000 if(itemid < 0 || !checkbunny(itemid))
2507 2526881174 continue;
2508
2509 70833826 itemdata const& itm = itemsbuf[itemid];
2510
2511
2/2
✓ Branch 0 taken 66371614 times.
✓ Branch 1 taken 4462212 times.
70833826 switch(itm.family)
2512 {
2513 case itype_shield:
2514
1/2
✓ Branch 0 taken 4462212 times.
✗ Branch 1 not taken.
4462212 if(itm.flags & ITEM_FLAG9) //active shield
2515 {
2516 if(!usingActiveShield(itemid))
2517 {
2518 tile+=itm.misc6; //'Inactive PTM'
2519 continue;
2520 }
2521 }
2522 4462212 break;
2523 }
2524
2525 70833826 tile+=itm.ltm;
2526 70833826 }
2527
2528 5075885 return tile;
2529 }
2530
2531 5075885 int32_t bunny_tile_mod()
2532 {
2533
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5074015 times.
5075885 if(Hero.BunnyClock())
2534 {
2535 1870 return game->get_bunny_ltm();
2536 }
2537 5074015 return 0;
2538 5075885 }
2539
2540 // Hints are drawn on a separate layer to combo reveals.
2541 16332 void draw_lens_under(BITMAP *dest, bool layer)
2542 {
2543 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2544 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2545 //Lens flag 3: Don't show armos/chest/dive items
2546 //Lens flag 4: Show Raft Paths
2547 //Lens flag 5: Show Invisible Enemies
2548
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2549
2550 16332 int32_t strike_hint_table[11]=
2551 {
2552 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2553 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2554 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2555 };
2556
2557 // int32_t page = tmpscr->cpage;
2558 {
2559 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2560 // int32_t temptimer=0;
2561 16332 int32_t tempitem, tempweapon=0;
2562 16332 strike_hint=strike_hint_table[strike_hint_counter];
2563
2564
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2565 {
2566 492 strike_hint_timer=0;
2567 492 strike_hint_counter=((strike_hint_counter+1)%11);
2568 492 }
2569
2570 16332 ++strike_hint_timer;
2571
2572
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2573 {
2574 2874432 int32_t x = (i & 15) << 4;
2575 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2576 2874432 int32_t tempitemx=-16, tempitemy=-16;
2577 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2578
2579
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2580 {
2581 5748864 int32_t checkflag=0;
2582
2583
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2584 {
2585 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2586 2874432 }
2587 else
2588 {
2589 2874432 checkflag=tmpscr->sflag[i];
2590 }
2591
2592
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2593 {
2594
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2595 {
2596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2597 906 }
2598 else
2599 {
2600 192 checkflag = strike_hint;
2601 }
2602 1098 }
2603
2604
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2605 {
2606 case 0:
2607 case mfZELDA:
2608 case mfPUSHED:
2609 case mfENEMY0:
2610 case mfENEMY1:
2611 case mfENEMY2:
2612 case mfENEMY3:
2613 case mfENEMY4:
2614 case mfENEMY5:
2615 case mfENEMY6:
2616 case mfENEMY7:
2617 case mfENEMY8:
2618 case mfENEMY9:
2619 case mfSINGLE:
2620 case mfSINGLE16:
2621 case mfNOENEMY:
2622 case mfTRAP_H:
2623 case mfTRAP_V:
2624 case mfTRAP_4:
2625 case mfTRAP_LR:
2626 case mfTRAP_UD:
2627 case mfNOGROUNDENEMY:
2628 case mfNOBLOCKS:
2629 case mfSCRIPT1:
2630 case mfSCRIPT2:
2631 case mfSCRIPT3:
2632 case mfSCRIPT4:
2633 case mfSCRIPT5:
2634 case mfSCRIPT6:
2635 case mfSCRIPT7:
2636 case mfSCRIPT8:
2637 case mfSCRIPT9:
2638 case mfSCRIPT10:
2639 case mfSCRIPT11:
2640 case mfSCRIPT12:
2641 case mfSCRIPT13:
2642 case mfSCRIPT14:
2643 case mfSCRIPT15:
2644 case mfSCRIPT16:
2645 case mfSCRIPT17:
2646 case mfSCRIPT18:
2647 case mfSCRIPT19:
2648 case mfSCRIPT20:
2649 case mfPITHOLE:
2650 case mfPITFALLFLOOR:
2651 case mfLAVA:
2652 case mfICE:
2653 case mfICEDAMAGE:
2654 case mfDAMAGE1:
2655 case mfDAMAGE2:
2656 case mfDAMAGE4:
2657 case mfDAMAGE8:
2658 case mfDAMAGE16:
2659 case mfDAMAGE32:
2660 case mfFREEZEALL:
2661 case mfFREZEALLANSFFCS:
2662 case mfFREEZEFFCSOLY:
2663 case mfSCRITPTW1TRIG:
2664 case mfSCRITPTW2TRIG:
2665 case mfSCRITPTW3TRIG:
2666 case mfSCRITPTW4TRIG:
2667 case mfSCRITPTW5TRIG:
2668 case mfSCRITPTW6TRIG:
2669 case mfSCRITPTW7TRIG:
2670 case mfSCRITPTW8TRIG:
2671 case mfSCRITPTW9TRIG:
2672 case mfSCRITPTW10TRIG:
2673 case mfTROWEL:
2674 case mfTROWELNEXT:
2675 case mfTROWELSPECIALITEM:
2676 case mfSLASHPOT:
2677 case mfLIFTPOT:
2678 case mfLIFTORSLASH:
2679 case mfLIFTROCK:
2680 case mfLIFTROCKHEAVY:
2681 case mfDROPITEM:
2682 case mfSPECIALITEM:
2683 case mfDROPKEY:
2684 case mfDROPLKEY:
2685 case mfDROPCOMPASS:
2686 case mfDROPMAP:
2687 case mfDROPBOSSKEY:
2688 case mfSPAWNNPC:
2689 case mfSWITCHHOOK:
2690 case mfSIDEVIEWLADDER:
2691 case mfSIDEVIEWPLATFORM:
2692 case mfNOENEMYSPAWN:
2693 case mfENEMYALL:
2694 case mfNOMIRROR:
2695 case mfUNSAFEGROUND:
2696 case mf168:
2697 case mf169:
2698 case mf170:
2699 case mf171:
2700 case mf172:
2701 case mf173:
2702 case mf174:
2703 case mf175:
2704 case mf176:
2705 case mf177:
2706 case mf178:
2707 case mf179:
2708 case mf180:
2709 case mf181:
2710 case mf182:
2711 case mf183:
2712 case mf184:
2713 case mf185:
2714 case mf186:
2715 case mf187:
2716 case mf188:
2717 case mf189:
2718 case mf190:
2719 case mf191:
2720 case mf192:
2721 case mf193:
2722 case mf194:
2723 case mf195:
2724 case mf196:
2725 case mf197:
2726 case mf198:
2727 case mf199:
2728 case mf200:
2729 case mf201:
2730 case mf202:
2731 case mf203:
2732 case mf204:
2733 case mf205:
2734 case mf206:
2735 case mf207:
2736 case mf208:
2737 case mf209:
2738 case mf210:
2739 case mf211:
2740 case mf212:
2741 case mf213:
2742 case mf214:
2743 case mf215:
2744 case mf216:
2745 case mf217:
2746 case mf218:
2747 case mf219:
2748 case mf220:
2749 case mf221:
2750 case mf222:
2751 case mf223:
2752 case mf224:
2753 case mf225:
2754 case mf226:
2755 case mf227:
2756 case mf228:
2757 case mf229:
2758 case mf230:
2759 case mf231:
2760 case mf232:
2761 case mf233:
2762 case mf234:
2763 case mf235:
2764 case mf236:
2765 case mf237:
2766 case mf238:
2767 case mf239:
2768 case mf240:
2769 case mf241:
2770 case mf242:
2771 case mf243:
2772 case mf244:
2773 case mf245:
2774 case mf246:
2775 case mf247:
2776 case mf248:
2777 case mf249:
2778 case mf250:
2779 case mf251:
2780 case mf252:
2781 case mf253:
2782 case mf254:
2783 case mfEXTENDED:
2784 5706470 break;
2785
2786 case mfPUSHUD:
2787 case mfPUSHLR:
2788 case mfPUSH4:
2789 case mfPUSHU:
2790 case mfPUSHD:
2791 case mfPUSHL:
2792 case mfPUSHR:
2793 case mfPUSHUDNS:
2794 case mfPUSHLRNS:
2795 case mfPUSH4NS:
2796 case mfPUSHUNS:
2797 case mfPUSHDNS:
2798 case mfPUSHLNS:
2799 case mfPUSHRNS:
2800 case mfPUSHUDINS:
2801 case mfPUSHLRINS:
2802 case mfPUSH4INS:
2803 case mfPUSHUINS:
2804 case mfPUSHDINS:
2805 case mfPUSHLINS:
2806 case mfPUSHRINS:
2807
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2808
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2809 {
2810 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2811 }
2812
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2814
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2815 {
2816
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2817 {
2818
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2819 {
2820 case cPUSH_HEAVY:
2821 case cPUSH_HW:
2822 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2823 72 tempitemx=x, tempitemy=y;
2824
2825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2826 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2827
2828 72 break;
2829
2830 case cPUSH_HEAVY2:
2831 case cPUSH_HW2:
2832 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2833 63 tempitemx=x, tempitemy=y;
2834
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2836 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837
2838 63 break;
2839 }
2840 1032 }
2841 2438 }
2842
2843 3148 break;
2844
2845 case mfWHISTLE:
2846
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2847 {
2848 tempitem=getItemID(itemsbuf,itype_whistle,1);
2849
2850 if(tempitem<0) break;
2851
2852 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2853 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2854 {
2855 tempitemx=x;
2856 tempitemy=y;
2857 }
2858
2859 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2860 }
2861
2862 2418 break;
2863
2864 //Why is this here?
2865 case mfFAIRY:
2866 case mfMAGICFAIRY:
2867 case mfALLFAIRY:
2868 if(hints)
2869 {
2870 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2871
2872 if(tempitem < 0) break;
2873
2874 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2875 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2876 {
2877 tempitemx=x;
2878 tempitemy=y;
2879 }
2880
2881 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2882 }
2883
2884 break;
2885
2886 case mfANYFIRE:
2887
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2888 {
2889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2890 252 }
2891 else
2892 {
2893 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2894
2895
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2896
2897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2898
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2899 {
2900 189 tempitemx=x;
2901 189 tempitemy=y;
2902 189 }
2903
2904 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 504 break;
2908
2909 case mfSTRONGFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_candle,2);
2917
2918 if(tempitem<0) break;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926
2927 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2928 }
2929
2930 break;
2931
2932 case mfMAGICFIRE:
2933 if(!hints)
2934 {
2935 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2936 }
2937 else
2938 {
2939 tempitem=getItemID(itemsbuf,itype_wand,1);
2940
2941 if(tempitem<0) break;
2942
2943 tempweapon=wFire;
2944
2945 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2946 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2947 {
2948 tempitemx=x;
2949 tempitemy=y;
2950 }
2951 else
2952 {
2953 tempweaponx=x;
2954 tempweapony=y;
2955 }
2956
2957 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2958 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2959 }
2960
2961 break;
2962
2963 case mfDIVINEFIRE:
2964 if(!hints)
2965 {
2966 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2967 }
2968 else
2969 {
2970 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2971
2972 if(tempitem<0) break;
2973
2974 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2975 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2976 {
2977 tempitemx=x;
2978 tempitemy=y;
2979 }
2980
2981 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2982 }
2983
2984 break;
2985
2986 case mfARROW:
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2988 {
2989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2990 732 }
2991 else
2992 {
2993 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2994
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2996
2997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2998
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2999 {
3000 61 tempitemx=x;
3001 61 tempitemy=y;
3002 61 }
3003
3004 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3005 }
3006
3007 814 break;
3008
3009 case mfSARROW:
3010 if(!hints)
3011 {
3012 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3013 }
3014 else
3015 {
3016 tempitem=getItemID(itemsbuf,itype_arrow,2);
3017
3018 if(tempitem<0) break;
3019
3020 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3021 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3022 {
3023 tempitemx=x;
3024 tempitemy=y;
3025 }
3026
3027 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3028 }
3029
3030 break;
3031
3032 case mfGARROW:
3033 if(!hints)
3034 {
3035 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3036 }
3037 else
3038 {
3039 tempitem=getItemID(itemsbuf,itype_arrow,3);
3040
3041 if(tempitem<0) break;
3042
3043 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 tempitemx=x;
3047 tempitemy=y;
3048 }
3049
3050 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3051 }
3052
3053 break;
3054
3055 case mfBOMB:
3056
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3057 {
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3059 16 }
3060 else
3061 {
3062 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3063 17 tempweapon = wLitBomb;
3064
3065 //if (tempitem<0) break;
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 12 tempweaponx=x;
3070 12 tempweapony=y;
3071 12 }
3072
3073 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3074 }
3075
3076 33 break;
3077
3078 case mfSBOMB:
3079
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3080 {
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3082 48 }
3083 else
3084 {
3085 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3086 //if (tempitem<0) break;
3087 48 tempweapon = wLitSBomb;
3088
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 36 tempweaponx=x;
3093 36 tempweapony=y;
3094 36 }
3095
3096 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3097 }
3098
3099 96 break;
3100
3101 case mfARMOS_SECRET:
3102
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3103 {
3104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3105 12 }
3106 24 break;
3107
3108 case mfBRANG:
3109
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3110 {
3111 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3112 }
3113 else
3114 {
3115 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3116
3117
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3118
3119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3120
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3121 {
3122 4 tempitemx=x;
3123 4 tempitemy=y;
3124 4 }
3125
3126 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3127 }
3128
3129 5 break;
3130
3131 case mfMBRANG:
3132 if(!hints)
3133 {
3134 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3135 }
3136 else
3137 {
3138 tempitem=getItemID(itemsbuf,itype_brang,2);
3139
3140 if(tempitem<0) break;
3141
3142 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3143 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3144 {
3145 tempitemx=x;
3146 tempitemy=y;
3147 }
3148
3149 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3150 }
3151
3152 break;
3153
3154 case mfFBRANG:
3155 if(!hints)
3156 {
3157 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3158 }
3159 else
3160 {
3161 tempitem=getItemID(itemsbuf,itype_brang,3);
3162
3163 if(tempitem<0) break;
3164
3165 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3166 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3167 {
3168 tempitemx=x;
3169 tempitemy=y;
3170 }
3171
3172 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3173 }
3174
3175 break;
3176
3177 case mfWANDMAGIC:
3178 if(!hints)
3179 {
3180 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3181 }
3182 else
3183 {
3184 tempitem=getItemID(itemsbuf,itype_wand,1);
3185
3186 if(tempitem<0) break;
3187
3188 tempweapon=itemsbuf[tempitem].wpn3;
3189
3190 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 tempitemx=x;
3194 tempitemy=y;
3195 }
3196 else
3197 {
3198 tempweaponx=x;
3199 tempweapony=y;
3200 --lens_hint_weapon[wMagic][4];
3201
3202 if(lens_hint_weapon[wMagic][4]<-8)
3203 {
3204 lens_hint_weapon[wMagic][4]=8;
3205 }
3206 }
3207
3208 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3209 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3210 }
3211
3212 break;
3213
3214 case mfREFMAGIC:
3215
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3216 {
3217 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3218 }
3219 else
3220 {
3221 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3222
3223
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3224
3225 16 tempweapon=ewMagic;
3226
3227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3228
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3229 {
3230 13 tempitemx=x;
3231 13 tempitemy=y;
3232 13 }
3233 else
3234 {
3235 3 tempweaponx=x;
3236 3 tempweapony=y;
3237
3238
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3239 {
3240 1 --lens_hint_weapon[ewMagic][4];
3241 1 }
3242 else
3243 {
3244 2 ++lens_hint_weapon[ewMagic][4];
3245 }
3246
3247
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3248 {
3249 lens_hint_weapon[ewMagic][2]=up;
3250 }
3251
3252
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3253 {
3254 2 lens_hint_weapon[ewMagic][2]=down;
3255 2 }
3256 }
3257
3258 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3259 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3260 }
3261
3262 16 break;
3263
3264 case mfREFFIREBALL:
3265
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3266 {
3267 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3268 }
3269 else
3270 {
3271 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3272
3273
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3274
3275 16 tempweapon=ewFireball;
3276
3277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3278
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3279 {
3280 12 tempitemx=x;
3281 12 tempitemy=y;
3282 12 tempweaponx=x;
3283 12 tempweapony=y;
3284 12 ++lens_hint_weapon[ewFireball][3];
3285
3286
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3287 {
3288 1 lens_hint_weapon[ewFireball][3]=-8;
3289 1 lens_hint_weapon[ewFireball][4]=8;
3290 1 }
3291
3292
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3293 {
3294 8 ++lens_hint_weapon[ewFireball][4];
3295 8 }
3296 else
3297 {
3298 4 --lens_hint_weapon[ewFireball][4];
3299 }
3300 12 }
3301
3302 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3303 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3304 }
3305
3306 16 break;
3307
3308 case mfSWORD:
3309
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3312 }
3313 else
3314 {
3315 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3316
3317
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3318
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 5 tempitemx=x;
3323 5 tempitemy=y;
3324 5 }
3325
3326 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3327 }
3328
3329 7 break;
3330
3331 case mfWSWORD:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,2);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3350 }
3351
3352 break;
3353
3354 case mfMSWORD:
3355 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3358 }
3359 else
3360 {
3361 tempitem=getItemID(itemsbuf,itype_sword,3);
3362
3363 if(tempitem<0) break;
3364
3365 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 tempitemx=x;
3369 tempitemy=y;
3370 }
3371
3372 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 break;
3376
3377 case mfXSWORD:
3378 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3381 }
3382 else
3383 {
3384 tempitem=getItemID(itemsbuf,itype_sword,4);
3385
3386 if(tempitem<0) break;
3387
3388 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 tempitemx=x;
3392 tempitemy=y;
3393 }
3394
3395 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3396 }
3397
3398 break;
3399
3400 case mfSWORDBEAM:
3401
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3404 }
3405 else
3406 {
3407 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3408
3409
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3410
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 11 tempitemx=x;
3415 11 tempitemy=y;
3416 11 }
3417
3418 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3419 }
3420
3421 16 break;
3422
3423 case mfWSWORDBEAM:
3424 if(!hints)
3425 {
3426 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3427 }
3428 else
3429 {
3430 tempitem=getItemID(itemsbuf,itype_sword,2);
3431
3432 if(tempitem<0) break;
3433
3434 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3435 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3436 {
3437 tempitemx=x;
3438 tempitemy=y;
3439 }
3440
3441 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3442 }
3443
3444 break;
3445
3446 case mfMSWORDBEAM:
3447 if(!hints)
3448 {
3449 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3450 }
3451 else
3452 {
3453 tempitem=getItemID(itemsbuf,itype_sword,3);
3454
3455 if(tempitem<0) break;
3456
3457 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3458 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3459 {
3460 tempitemx=x;
3461 tempitemy=y;
3462 }
3463
3464 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3465 }
3466
3467 break;
3468
3469 case mfXSWORDBEAM:
3470 if(!hints)
3471 {
3472 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3473 }
3474 else
3475 {
3476 tempitem=getItemID(itemsbuf,itype_sword,4);
3477
3478 if(tempitem<0) break;
3479
3480 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3481 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3482 {
3483 tempitemx=x;
3484 tempitemy=y;
3485 }
3486
3487 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3488 }
3489
3490 break;
3491
3492 case mfHOOKSHOT:
3493
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3494 {
3495 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3496 }
3497 else
3498 {
3499 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3500
3501
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3502
3503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3504
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3505 {
3506 12 tempitemx=x;
3507 12 tempitemy=y;
3508 12 }
3509
3510 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3511 }
3512
3513 17 break;
3514
3515 case mfWAND:
3516
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3517 {
3518 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3519 }
3520 else
3521 {
3522 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3523
3524
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3525
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3527
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3528 {
3529 28 tempitemx=x;
3530 28 tempitemy=y;
3531 28 }
3532
3533 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3534 }
3535
3536 35 break;
3537
3538 case mfHAMMER:
3539
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3540 {
3541 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3542 }
3543 else
3544 {
3545 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3546
3547
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3548
3549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3550
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3551 {
3552 13 tempitemx=x;
3553 13 tempitemy=y;
3554 13 }
3555
3556 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3557 }
3558
3559 17 break;
3560
3561 case mfARMOS_ITEM:
3562 case mfDIVE_ITEM:
3563
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3564 {
3565 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3566 2064 }
3567 2064 break;
3568
3569 case 16:
3570 case 17:
3571 case 18:
3572 case 19:
3573 case 20:
3574 case 21:
3575 case 22:
3576 case 23:
3577 case 24:
3578 case 25:
3579 case 26:
3580 case 27:
3581 case 28:
3582 case 29:
3583 case 30:
3584 case 31:
3585
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3587 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3588
3589 3618 break;
3590 case mfSECRETSNEXT:
3591 if(!hints)
3592 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3593 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3594
3595 break;
3596
3597 case mfSTRIKE:
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3599 {
3600 906 goto special;
3601 }
3602 else
3603 {
3604 break;
3605 }
3606
3607 28640 default: goto special;
3608
3609 special:
3610
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3611 {
3612
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3613 {
3614 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3615 4913 }
3616 6549 }
3617
3618 29546 break;
3619 }
3620 5748864 }
3621 2874432 }
3622
3623
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3624 {
3625
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3626 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3627
3628
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3629 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3630
3631
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3632 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3633
3634
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3635 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3636
3637
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3638 {
3639 43 showbombeddoor(dest, 0);
3640 43 }
3641
3642
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3643 {
3644 39 showbombeddoor(dest, 1);
3645 39 }
3646
3647
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3648 {
3649 showbombeddoor(dest, 2);
3650 }
3651
3652
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3653 {
3654 37 showbombeddoor(dest, 3);
3655 37 }
3656 8166 }
3657
3658
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3659 {
3660
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3661 {
3662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3663 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3664 1123 }
3665 else
3666 {
3667
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3668 {
3669 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3670 48 int32_t tempitemx=-16;
3671 48 int32_t tempitemy=-16;
3672
3673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3674
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3675 {
3676 24 tempitemx=tmpscr->stairx;
3677 24 tempitemy=tmpscr->stairy+playing_field_offset;
3678 24 }
3679
3680 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3681 48 }
3682 }
3683 2034 }
3684 }
3685 16332 }
3686
3687 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3688
3689 7997 void draw_lens_over()
3690 {
3691 // Oh, what the heck.
3692 static BITMAP *lens_scr = NULL;
3693 static int32_t last_width = -1;
3694 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3695
3696 // Only redraw the circle if the size has changed
3697
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3698 {
3699
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3700 {
3701 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3702 5 }
3703
3704 5 clear_to_color(lens_scr, BLACK);
3705 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3706 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3707 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3708 5 last_width=width;
3709 5 }
3710
3711 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3712 7997 }
3713
3714 //----------------------------------------------------------------
3715
3716 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3717 {
3718 //recreating a big bitmap every frame is highly sluggish.
3719
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3720 30701 clear_to_color(wavebuf, BLACK);
3721 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3722
3723 int32_t ofs;
3724 // int32_t amplitude=8;
3725 // int32_t wavelength=4;
3726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3727
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3728 30701 int32_t amp2=168;
3729
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3730 30701 int32_t i=frame%amp2;
3731
3732
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3733 {
3734
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3735 {
3736 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3737 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3738 }
3739 else
3740 {
3741 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3742 }
3743
3744
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3745 {
3746
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3747 {
3748 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3749 1320388608 }
3750 5157768 }
3751 5157768 }
3752 30701 }
3753
3754 3360 void draw_fuzzy(int32_t fuzz)
3755 // draws from right half of scrollbuf to framebuf
3756 {
3757 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3758 byte *start, *si, *di;
3759
3760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3761 fuzz = 1;
3762
3763 3360 xstep = 128%fuzz;
3764
3765
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3766 2660 xstep = fuzz-xstep;
3767
3768 3360 ystep = 112%fuzz;
3769
3770
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3771 2380 ystep = fuzz-ystep;
3772
3773 3360 firsty = 1;
3774
3775
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3776 {
3777 121240 start = &(scrollbuf->line[y][256]);
3778
3779
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3780 {
3781 752640 si = start;
3782 752640 di = &(framebuf->line[y+dy][0]);
3783 752640 i = xstep;
3784 752640 firstx = 1;
3785
3786
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3787 {
3788 192675840 *(di++) = *si;
3789
3790
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3791 {
3792
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3793 29572480 si += fuzz;
3794 else
3795 {
3796 752640 si += fuzz-xstep;
3797 752640 firstx = 0;
3798 }
3799
3800 30325120 i = 0;
3801 30325120 }
3802 192675840 }
3803 752640 }
3804
3805
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3806 117880 y += fuzz;
3807 else
3808 {
3809 3360 y += ystep;
3810 3360 ystep = fuzz;
3811 3360 firsty = 0;
3812 }
3813 }
3814 3360 }
3815
3816 8132353 void updatescr(bool allowwavy)
3817 {
3818
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8132320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
8132353 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3819
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8132320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
8132353 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3820
3821
2/2
✓ Branch 0 taken 8106649 times.
✓ Branch 1 taken 25704 times.
8132353 if(toogam)
3822 {
3823 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3824 25704 }
3825
3826
1/2
✓ Branch 0 taken 8132353 times.
✗ Branch 1 not taken.
8132353 if(Showpal)
3827 dump_pal(framebuf);
3828
3829
2/2
✓ Branch 0 taken 7954422 times.
✓ Branch 1 taken 177931 times.
8132353 if(!Playing)
3830 177931 black_opening_count=0;
3831
3832
2/2
✓ Branch 0 taken 8078101 times.
✓ Branch 1 taken 54252 times.
8132353 if(black_opening_count<0) //shape is opening up
3833 {
3834 54252 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3835
3836
2/4
✓ Branch 0 taken 54252 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54252 times.
54252 if(Advance||(!Paused))
3837 {
3838 54252 ++black_opening_count;
3839 54252 }
3840 54252 }
3841
2/2
✓ Branch 0 taken 8057509 times.
✓ Branch 1 taken 20592 times.
8078101 else if(black_opening_count>0) //shape is closing
3842 {
3843 20592 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3844
3845
2/4
✓ Branch 0 taken 20592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20592 times.
20592 if(Advance||(!Paused))
3846 {
3847 20592 --black_opening_count;
3848 20592 }
3849 20592 }
3850
3851
3/4
✓ Branch 0 taken 8058643 times.
✓ Branch 1 taken 73710 times.
✓ Branch 2 taken 8058643 times.
✗ Branch 3 not taken.
8132353 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3852 {
3853 black_opening_shape = bosCIRCLE;
3854 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3855 refreshTints();
3856 refreshpal=true;
3857 }
3858
3859
2/2
✓ Branch 0 taken 7887462 times.
✓ Branch 1 taken 244891 times.
8132353 if(refreshpal)
3860 {
3861 244891 refreshpal=false;
3862 244891 RAMpal[253] = _RGB(0,0,0);
3863 244891 RAMpal[254] = _RGB(63,63,63);
3864 244891 hw_palette = &RAMpal;
3865 244891 update_hw_pal = true;
3866
3867 244891 create_rgb_table(&rgb_table, RAMpal, NULL);
3868 244891 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3869 244891 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3870
3871
2/2
✓ Branch 0 taken 62692096 times.
✓ Branch 1 taken 244891 times.
62936987 for(int32_t q=0; q<PAL_SIZE; q++)
3872 {
3873 62692096 trans_table2.data[0][q] = q;
3874 62692096 trans_table2.data[q][q] = q;
3875 62692096 }
3876 244891 }
3877
3878 8132353 bool clearwavy = (wavy <= 0);
3879
3880
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8125108 times.
8132353 if(wavy <= 0)
3881 {
3882 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3883 8125108 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3884 8125108 }
3885
3886 8132353 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3887
3888
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8101402 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8132353 if(wavy && Playing && allowwavy)
3889 {
3890 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3891 30701 }
3892
3893
2/2
✓ Branch 0 taken 8125108 times.
✓ Branch 1 taken 7245 times.
8132353 if(clearwavy)
3894 8125108 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3895
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3896 7245 wavy--; // Wavy was set by a script. Decrement it.
3897
3898
5/6
✓ Branch 0 taken 7954422 times.
✓ Branch 1 taken 177931 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7769926 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8132353 if(Playing && msgpos && !screenscrolling)
3899 {
3900
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3901 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3902
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3903 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3904
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3905 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3906 184496 }
3907
3908 /*
3909 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3910 {
3911 BITMAP* subBmp = 0;
3912 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3913 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3914 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3915 destroy_bitmap(subBmp);
3916 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3917 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3918 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3919 }
3920 */
3921
3922
2/2
✓ Branch 0 taken 8094836 times.
✓ Branch 1 taken 37517 times.
8132353 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3923
3924
2/2
✓ Branch 0 taken 8099461 times.
✓ Branch 1 taken 32892 times.
8132353 if(nosubscr)
3925 {
3926 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3927 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3928 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3929 32892 }
3930
3931 //TODO: Optimize blit 'overcalls' -Gleeok
3932
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8099461 times.
8132353 BITMAP *source = nosubscr ? panorama : wavybuf;
3933 8132353 blit(source,framebuf,0,0,0,0,256,224);
3934
3935 8132353 update_hw_screen();
3936 8132353 }
3937
3938 //----------------------------------------------------------------
3939
3940 PALETTE sys_pal;
3941
3942 int32_t onGUISnapshot()
3943 {
3944 char buf[200];
3945 int32_t num=0;
3946 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3947 do
3948 {
3949 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3950 }
3951 while(num<99999 && exists(buf));
3952
3953 BITMAP *b = create_bitmap_ex(8,resx,resy);
3954
3955 if(b)
3956 {
3957 if(MenuOpen)
3958 {
3959 //Cannot load game's palette while GUI elements are in focus. -Z
3960 //If there is a way to do this, then I have missed it.
3961 /*
3962 game_pal();
3963 RAMpal[253] = _RGB(0,0,0);
3964 RAMpal[254] = _RGB(63,63,63);
3965 zc_set_palette_range(RAMpal,0,255,false);
3966 memcpy(RAMpal, snappal, sizeof(snappal));
3967 create_rgb_table(&rgb_table, RAMpal, NULL);
3968 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3969 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3970
3971 for(int32_t q=0; q<PAL_SIZE; q++)
3972 {
3973 trans_table2.data[0][q] = q;
3974 trans_table2.data[q][q] = q;
3975 }
3976 */
3977 //ringcolor(false);
3978 //get_palette(RAMpal);
3979 blit(screen,b,0,0,0,0,resx,resy);
3980 //al_trace("Menu Open\n");
3981 //game_pal();
3982 //PALETTE temppal;
3983 //get_palette(temppal);
3984 //system_pal();
3985 save_bitmap(buf,b,sys_pal);
3986 //save_bitmap(buf,b,RAMpal);
3987 //save_bitmap(buf,b,snappal);
3988 }
3989 else
3990 {
3991 blit(screen,b,0,0,0,0,resx,resy);
3992 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3993 }
3994 destroy_bitmap(b);
3995 }
3996
3997 return D_O_K;
3998 }
3999
4000 int32_t onNonGUISnapshot()
4001 {
4002 PALETTE temppal;
4003 get_palette(temppal);
4004 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
4005
4006 char buf[200];
4007 int32_t num=0;
4008
4009 do
4010 {
4011 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4012 }
4013 while(num<99999 && exists(buf));
4014
4015 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4016
4017 return D_O_K;
4018 }
4019
4020 int32_t onSnapshot()
4021 {
4022 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4023 {
4024 onGUISnapshot();
4025 }
4026 else
4027 {
4028 onNonGUISnapshot();
4029 }
4030
4031 return D_O_K;
4032 }
4033
4034 int32_t onSaveMapPic()
4035 {
4036 int32_t mapres2 = 0;
4037 char buf[200];
4038 int32_t num=0;
4039 mapscr tmpscr_b[2];
4040 mapscr tmpscr_c[6];
4041 BITMAP* _screen_draw_buffer = NULL;
4042 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4043 set_clip_state(_screen_draw_buffer,1);
4044
4045 for(int32_t i=0; i<6; ++i)
4046 {
4047 tmpscr_c[i] = tmpscr2[i];
4048 tmpscr2[i].zero_memory();
4049
4050 if(i>=2)
4051 {
4052 continue;
4053 }
4054
4055 tmpscr_b[i] = tmpscr[i];
4056 tmpscr[i].zero_memory();
4057 }
4058
4059 do
4060 {
4061 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4062 }
4063 while(num<99999 && exists(buf));
4064
4065 BITMAP* mappic = NULL;
4066
4067
4068 bool done=false, redraw=true;
4069
4070 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4071
4072 if(!mappic)
4073 {
4074 system_pal();
4075 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4076 game_pal();
4077 return D_O_K;;
4078 }
4079
4080 // draw the map
4081 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4082
4083 for(int32_t y=0; y<8; y++)
4084 {
4085 for(int32_t x=0; x<16; x++)
4086 {
4087 if(!displayOnMap(x, y))
4088 {
4089 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4090 }
4091 else
4092 {
4093 int32_t s = (y<<4) + x;
4094 loadscr2(1,s,-1);
4095
4096 for(int32_t i=0; i<6; i++)
4097 {
4098 if(tmpscr[1].layermap[i]<=0)
4099 continue;
4100
4101 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4102 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4103 {
4104 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4105
4106 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4107 }
4108 }
4109
4110 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4111
4112 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4113
4114 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4115 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4116
4117 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4120 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4121 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4122 {
4123 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4124 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4125 }
4126 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4127
4128 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4129
4130 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4131 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4132 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4133 {
4134 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4135 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4136 }
4137 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4138 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4139
4140 }
4141
4142 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4143 }
4144 }
4145
4146 for(int32_t i=0; i<6; ++i)
4147 {
4148 tmpscr2[i]=tmpscr_c[i];
4149
4150 if(i>=2)
4151 {
4152 continue;
4153 }
4154
4155 tmpscr[i]=tmpscr_b[i];
4156 }
4157
4158 save_bitmap(buf,mappic,RAMpal);
4159 destroy_bitmap(mappic);
4160 destroy_bitmap(_screen_draw_buffer);
4161 return D_O_K;
4162 }
4163
4164 /*
4165 int32_t onSaveMapPic()
4166 {
4167 BITMAP* mappic = NULL;
4168 BITMAP* _screen_draw_buffer = NULL;
4169 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4170 int32_t mapres2 = 0;
4171 char buf[20];
4172 int32_t num=0;
4173 set_clip_state(_screen_draw_buffer,1);
4174 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4175
4176 do
4177 {
4178 sprintf(buf, "zelda%03d.png", ++num);
4179 }
4180 while(num<999 && exists(buf));
4181
4182 // if(!mappic) {
4183 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4184
4185 if(!mappic)
4186 {
4187 system_pal();
4188 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4189 game_pal();
4190 return D_O_K;
4191 }
4192
4193 // }
4194
4195 int32_t layermap, layerscreen;
4196 int32_t x2=0;
4197
4198 // draw the map
4199 for(int32_t y=0; y<8; y++)
4200 {
4201 for(int32_t x=0; x<16; x++)
4202 {
4203 int32_t s = (y<<4) + x;
4204
4205 if(!displayOnMap(x, y))
4206 {
4207 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4208 }
4209 else
4210 {
4211 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4212 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4213
4214 for(int32_t k=0; k<4; k++)
4215 {
4216 if(k==2)
4217 {
4218 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4219 }
4220
4221 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4222
4223 if(layermap>-1)
4224 {
4225 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4226
4227 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4228 {
4229 for(int32_t i=0; i<176; i++)
4230 {
4231 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4232 }
4233 }
4234 else
4235 {
4236 for(int32_t i=0; i<176; i++)
4237 {
4238 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4239 }
4240 }
4241 }
4242 }
4243
4244 for(int32_t i=0; i<176; i++)
4245 {
4246 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4247 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4248 {
4249 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4250 }
4251 }
4252
4253 for(int32_t k=4; k<6; k++)
4254 {
4255 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4256
4257 if(layermap>-1)
4258 {
4259 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4260
4261 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4262 {
4263 for(int32_t i=0; i<176; i++)
4264 {
4265 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4266 }
4267 }
4268 else
4269 {
4270 for(int32_t i=0; i<176; i++)
4271 {
4272 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4273 }
4274 }
4275 }
4276 }
4277 }
4278
4279 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4280 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4281 }
4282
4283 }
4284
4285 save_bitmap(buf,mappic,RAMpal);
4286 destroy_bitmap(mappic);
4287 destroy_bitmap(_screen_draw_buffer);
4288 return D_O_K;
4289 }
4290 */
4291
4292 14 void f_Quit(int32_t type)
4293 {
4294
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4295 return;
4296
4297 14 bool from_menu = is_sys_pal;
4298
4299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4300 {
4301 14 music_pause();
4302 14 pause_all_sfx();
4303 14 sys_mouse();
4304 14 }
4305 14 enter_sys_pal();
4306 14 clear_keybuf();
4307
4308
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4309 13 replay_poll();
4310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4311 14 replay_peek_quit();
4312
4313
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4314 switch(type)
4315 {
4316 case qQUIT:
4317 onQuit();
4318 break;
4319
4320 case qRESET:
4321 onReset();
4322 break;
4323
4324 case qEXIT:
4325 onExit();
4326 break;
4327 }
4328
4329
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4330 {
4331 14 kill_sfx();
4332 14 music_stop();
4333 14 exit_sys_pal();
4334 14 update_hw_screen();
4335 14 }
4336 else
4337 {
4338 exit_sys_pal();
4339 if(!from_menu)
4340 {
4341 music_resume();
4342 resume_all_sfx();
4343 }
4344 }
4345
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4347 14 game_mouse();
4348 14 eat_buttons();
4349
4350 14 zc_readrawkey(KEY_ESC);
4351
4352 14 zc_readrawkey(KEY_ENTER);
4353 14 }
4354
4355 //----------------------------------------------------------------
4356
4357 int32_t onNoWalls()
4358 {
4359 cheats_enqueue(Cheat::Walls);
4360 return D_O_K;
4361 }
4362
4363 int32_t onIgnoreSideview()
4364 {
4365 cheats_enqueue(Cheat::IgnoreSideView);
4366 return D_O_K;
4367 }
4368
4369 8132269 int32_t input_idle(bool checkmouse)
4370 {
4371 static int32_t mx, my, mz, mb;
4372
4373
4/6
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136415 times.
✓ Branch 3 taken 5995854 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2136415 times.
10268684 if(keypressed() || zc_key_pressed() ||
4374
4/8
✓ Branch 0 taken 2136415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2136415 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2136415 times.
✗ Branch 7 not taken.
2136415 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4375 {
4376 5995854 idle_count = 0;
4377
4378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5995854 times.
5995854 if(active_count < MAX_ACTIVE)
4379 {
4380 5995854 ++active_count;
4381 5995854 }
4382 5995854 }
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2136415 times.
2136415 else if(idle_count < MAX_IDLE)
4384 {
4385 2136415 ++idle_count;
4386 2136415 active_count = 0;
4387 2136415 }
4388
4389 8132269 mx = mouse_x;
4390 8132269 my = mouse_y;
4391 8132269 mz = mouse_z;
4392 8132269 mb = mouse_b;
4393
4394 8132269 return idle_count;
4395 }
4396
4397 int32_t onGoFast()
4398 {
4399 cheats_enqueue(Cheat::Fast);
4400 return D_O_K;
4401 }
4402
4403 int32_t onKillCheat()
4404 {
4405 cheats_enqueue(Cheat::Kill);
4406 return D_O_K;
4407 }
4408
4409 int32_t onSecretsCheat()
4410 {
4411 cheats_enqueue(Cheat::TrigSecrets);
4412 return D_O_K;
4413 }
4414 int32_t onSecretsCheatPerm()
4415 {
4416 cheats_enqueue(Cheat::TrigSecretsPerm);
4417 return D_O_K;
4418 }
4419
4420 int32_t onShowLayer0()
4421 {
4422 show_layer_0 = !show_layer_0;
4423 return D_O_K;
4424 }
4425 int32_t onShowLayer1()
4426 {
4427 show_layer_1 = !show_layer_1;
4428 return D_O_K;
4429 }
4430 int32_t onShowLayer2()
4431 {
4432 show_layer_2 = !show_layer_2;
4433 return D_O_K;
4434 }
4435 int32_t onShowLayer3()
4436 {
4437 show_layer_3 = !show_layer_3;
4438 return D_O_K;
4439 }
4440 int32_t onShowLayer4()
4441 {
4442 show_layer_4 = !show_layer_4;
4443 return D_O_K;
4444 }
4445 int32_t onShowLayer5()
4446 {
4447 show_layer_5 = !show_layer_5;
4448 return D_O_K;
4449 }
4450 int32_t onShowLayer6()
4451 {
4452 show_layer_6 = !show_layer_6;
4453 return D_O_K;
4454 }
4455 int32_t onShowLayerO()
4456 {
4457 show_layer_over=!show_layer_over;
4458 return D_O_K;
4459 }
4460 int32_t onShowLayerP()
4461 {
4462 show_layer_push=!show_layer_push;
4463 return D_O_K;
4464 }
4465 int32_t onShowLayerS()
4466 {
4467 show_sprites=!show_sprites;
4468 return D_O_K;
4469 }
4470 int32_t onShowLayerF()
4471 {
4472 show_ffcs=!show_ffcs;
4473 return D_O_K;
4474 }
4475 int32_t onShowLayerW()
4476 {
4477 show_walkflags=!show_walkflags;
4478 if(show_walkflags)
4479 show_effectflags = false;
4480 return D_O_K;
4481 }
4482 int32_t onShowLayerE()
4483 {
4484 show_effectflags=!show_effectflags;
4485 if(show_effectflags)
4486 show_walkflags = false;
4487 return D_O_K;
4488 }
4489 int32_t onShowFFScripts()
4490 {
4491 show_ff_scripts=!show_ff_scripts;
4492 return D_O_K;
4493 }
4494 int32_t onShowHitboxes()
4495 {
4496 show_hitboxes=!show_hitboxes;
4497 return D_O_K;
4498 }
4499 int32_t onShowInfoOpacity()
4500 {
4501 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4502 zc_set_config("zc","debug_info_opacity",info_opacity);
4503 return D_O_K;
4504 }
4505
4506 int32_t onLightSwitch()
4507 {
4508 cheats_enqueue(Cheat::Light);
4509 return D_O_K;
4510 }
4511
4512 int32_t onGoTo();
4513 int32_t onGoToComplete();
4514
4515 8132269 void syskeys()
4516 {
4517 8132269 update_system_keys();
4518
4519 int32_t oldtitle_version;
4520
4521
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(close_button_quit)
4522 {
4523 close_button_quit=false;
4524 f_Quit(qEXIT);
4525 }
4526
4527 8132269 poll_joystick();
4528
4529
2/10
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8132269 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8132269 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4530 {
4531 oldtitle_version=title_version;
4532 System();
4533 }
4534
4535 8132269 mouse_down=gui_mouse_b();
4536
4537
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F1))
4538 {
4539 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4540 {
4541 halt=!halt;
4542 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4543 }
4544 else
4545 {
4546 Throttlefps=!Throttlefps;
4547 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4548 logic_counter=0;
4549 }
4550 }
4551
4552 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4553 /*
4554 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4555 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4556 */
4557
4558
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F2))
4559 {
4560 ShowFPS=!ShowFPS;
4561 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4562 }
4563
4564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4565
4566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(zc_read_system_key(KEY_F4) && Playing)
4567 {
4568 Paused=true;
4569 Advance=true;
4570 }
4571
4572
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F6)) onTryQuit();
4573
4574 #ifndef ALLEGRO_MACOSX
4575
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4576
4577
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4578 #else
4579 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4580
4581 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4582 #endif
4583
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8132269 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4584
4585
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if (zc_read_system_key(KEY_F12))
4586 {
4587 onSnapshot();
4588 }
4589
4590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8132269 if(debug_enabled && zc_read_system_key(KEY_TAB))
4591 set_debug(!get_debug());
4592
4593
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(CheatModifierKeys())
4594 {
4595 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4596 {
4597 if(!bindable_cheat(c))
4598 continue;
4599 if(get_debug() || cheat >= cheat_lvl(c))
4600 {
4601 if(checkcheat(c))
4602 cheats_hit_bind(c);
4603 }
4604 }
4605 }
4606
4607
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(volkeys)
4608 {
4609 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4610
4611 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4612
4613 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4614
4615 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4616 }
4617
4618
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8132269 if(!get_debug() || !SystemKeys || replay_is_replaying())
4619 8132269 goto bottom;
4620
4621 if(zc_readkey(KEY_D))
4622 {
4623 details = !details;
4624 rectfill(screen,0,0,319,7,BLACK);
4625 rectfill(screen,0,8,31,239,BLACK);
4626 rectfill(screen,288,8,319,239,BLACK);
4627 rectfill(screen,32,232,287,239,BLACK);
4628 }
4629
4630 if(zc_readkey(KEY_P)) Paused=!Paused;
4631
4632 //if(zc_readkey(KEY_P)) centerHero();
4633 if(zc_readkey(KEY_A))
4634 {
4635 Paused=true;
4636 Advance=true;
4637 }
4638
4639 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4640 #ifndef ALLEGRO_MACOSX
4641 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4642
4643 if(zc_readkey(KEY_F7))
4644 {
4645 Matrix(ss_speed, ss_density, 0);
4646 game_pal();
4647 }
4648 #else
4649 // The reason these are different on Mac in the first place is that
4650 // the OS doesn't let us use F9 and F10...
4651 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4652
4653 if(zc_readkey(KEY_F9))
4654 {
4655 Matrix(ss_speed, ss_density, 0);
4656 game_pal();
4657 }
4658 #endif
4659 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4660 {
4661 //change containers
4662 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4663 {
4664 //magic containers
4665 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4666 {
4667 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4668 }
4669 else
4670 {
4671 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4672 }
4673 }
4674 else
4675 {
4676 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4677 {
4678 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4679 }
4680 else
4681 {
4682 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4683 }
4684 }
4685 }
4686
4687 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4688 {
4689 //change containers
4690 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4691 {
4692 //magic containers
4693 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4694 {
4695 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4696 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4697 //heart containers
4698 }
4699 else
4700 {
4701 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4702 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4703 }
4704 }
4705 else
4706 {
4707 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4708 {
4709 game->set_magic(zc_max(game->get_magic()-1,0));
4710 }
4711 else
4712 {
4713 game->set_life(zc_max(game->get_life()-1,0));
4714 }
4715 }
4716 }
4717
4718 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4719
4720 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4721
4722 verifyBothWeapons();
4723
4724 bottom:
4725
4726
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(input_idle(true) > after_time())
4727 {
4728 Matrix(ss_speed, ss_density, 0);
4729 game_pal();
4730 }
4731 8132269 }
4732
4733 429041 void checkQuitKeys()
4734 {
4735 #ifndef ALLEGRO_MACOSX
4736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429041 times.
429041 if(key[KEY_F9]) f_Quit(qRESET);
4737
4738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429041 times.
429041 if(key[KEY_F10]) f_Quit(qEXIT);
4739 #else
4740 if(key[KEY_F7]) f_Quit(qRESET);
4741
4742 if(key[KEY_F8]) f_Quit(qEXIT);
4743 #endif
4744 429041 }
4745
4746 8132269 bool CheatModifierKeys()
4747 {
4748 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4749 // to trigger cheats.
4750
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if (replay_is_replaying())
4751 8132269 return false;
4752
4753 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4754 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4755 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4756 {
4757 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4758 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4759 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4760 {
4761 return true;
4762 }
4763 }
4764 return false;
4765 8132269 }
4766
4767 //99:05:54, for some reason?
4768 #define OLDMAXTIME 21405240
4769 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4770 #define MAXTIME 1944000000
4771
4772 8132353 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4773 {
4774
2/2
✓ Branch 0 taken 7842198 times.
✓ Branch 1 taken 290155 times.
8132353 if(zcmusic!=NULL)
4775 {
4776 290155 zcmusic_poll();
4777 290155 }
4778
4779 8132353 updatescr(allowwavy);
4780
4781 8132353 Advance=false;
4782
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8132353 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8132353 times.
8132353 while(Paused && !Advance && !Quit)
4783 {
4784 // have to call this, otherwise we'll get an infinite loop
4785 syskeys();
4786 if(allowF6Script)
4787 {
4788 FFCore.runF6Engine();
4789 }
4790 throttleFPS();
4791
4792 #ifdef _WIN32
4793
4794 if(use_dwm_flush)
4795 {
4796 do_DwmFlush();
4797 }
4798
4799 #endif
4800
4801 // to keep music playing
4802 if(zcmusic!=NULL)
4803 {
4804 zcmusic_poll();
4805 }
4806
4807 update_hw_screen();
4808 }
4809
4810
2/2
✓ Branch 0 taken 8132281 times.
✓ Branch 1 taken 72 times.
8132353 if(Quit)
4811 72 return;
4812
4813
3/4
✓ Branch 0 taken 7954413 times.
✓ Branch 1 taken 177868 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7954413 times.
8132281 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4814 7954413 game->change_time(1);
4815
4816
3/4
✓ Branch 0 taken 8132281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1528134 times.
✓ Branch 3 taken 6604147 times.
8132281 if (!replay_is_active() || replay_get_version() >= 11)
4817
2/2
✓ Branch 0 taken 27506412 times.
✓ Branch 1 taken 1528134 times.
29034546 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4818 29034546 down_control_states[i] = raw_control_state[i];
4819
4820
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132289 times.
8132281 if (replay_is_active())
4821 {
4822
2/2
✓ Branch 0 taken 1270471 times.
✓ Branch 1 taken 6861818 times.
8132289 if (replay_get_version() >= 3)
4823 6861818 replay_poll();
4824
4825
6/6
✓ Branch 0 taken 6604137 times.
✓ Branch 1 taken 1528132 times.
✓ Branch 2 taken 3183485 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082950 times.
8132289 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4826 1628667 replay_peek_input();
4827 8132269 }
4828
4829 8132281 load_control_called_this_frame = false;
4830
4831 8132281 poll_keyboard();
4832 8132281 update_keys();
4833
4834 8132281 ++frame;
4835
4836
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132269 times.
8132281 if (replay_is_replaying())
4837 8132269 replay_do_cheats();
4838 8132281 syskeys();
4839
4840 // The mouse variables can change from the mouse thread at anytime during a frame,
4841 // so save the result at the start so that replaying is consistent.
4842 8132281 script_mouse_x = gui_mouse_x();
4843 8132281 script_mouse_y = gui_mouse_y();
4844 8132281 script_mouse_z = mouse_z;
4845 8132281 script_mouse_b = mouse_b;
4846
4847 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4848 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4849 // approach here means it doesn't matter which call adds the cheat.
4850 8132281 cheats_execute_queued();
4851
4852
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8132269 times.
8132281 if (replay_is_replaying())
4853 8132269 replay_peek_quit();
4854
2/2
✓ Branch 0 taken 8132267 times.
✓ Branch 1 taken 14 times.
8132281 if (GameFlags & GAMEFLAG_TRYQUIT)
4855 14 replay_step_quit(0);
4856
2/2
✓ Branch 0 taken 2567 times.
✓ Branch 1 taken 8129714 times.
8132281 if(allowF6Script)
4857 8129714 FFCore.runF6Engine();
4858
2/2
✓ Branch 0 taken 8132057 times.
✓ Branch 1 taken 224 times.
8132281 if (Quit)
4859 224 replay_step_quit(Quit);
4860 // Someday... maybe install a Turbo button here?
4861 8132281 throttleFPS();
4862
4863 #ifdef _WIN32
4864
4865 if(use_dwm_flush)
4866 {
4867 do_DwmFlush();
4868 }
4869
4870 #endif
4871
4872 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4873
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8085587 times.
8132281 if(sfxcleanup)
4874 8085587 sfx_cleanup();
4875 8132353 }
4876
4877 70 void zapout()
4878 {
4879 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4880 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4881
4882 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4883 70 script_drawing_commands.Clear();
4884
4885 // zap out
4886
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4887 {
4888 1680 draw_fuzzy(i);
4889 1680 advanceframe(true);
4890
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4892 {
4893 break;
4894 }
4895 1680 }
4896 70 }
4897
4898 70 void zapin()
4899 {
4900 70 FFCore.warpScriptCheck();
4901 70 draw_screen(tmpscr);
4902 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4903 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4904 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4905
4906 // zap out
4907 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4908
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4909 {
4910 1680 draw_fuzzy(i);
4911 1680 advanceframe(true);
4912
4913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4914 {
4915 break;
4916 }
4917 1680 }
4918 70 }
4919
4920
4921 38 void wavyout(bool showhero)
4922 {
4923 38 draw_screen(tmpscr, showhero);
4924 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4925
4926 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4927 38 clear_to_color(wavebuf,0);
4928 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4929
4930 static PALETTE wavepal;
4931
4932 int32_t ofs;
4933 38 int32_t amplitude=8;
4934
4935 38 int32_t wavelength=4;
4936 38 double palpos=0, palstep=4, palstop=126;
4937
4938 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4939
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4940 {
4941
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4942 {
4943 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4944 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4945 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4946 408576 }
4947
4948 1596 palpos+=palstep;
4949
4950
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4951 {
4952 1596 hw_palette = &wavepal;
4953 1596 update_hw_pal = true;
4954 1596 }
4955 else
4956 {
4957 hw_palette = &RAMpal;
4958 update_hw_pal = true;
4959 }
4960
4961
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4962 {
4963
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4964 {
4965 68640768 ofs=0;
4966
4967
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4968 {
4969 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4970 16751616 }
4971
4972 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4973 68640768 }
4974 268128 }
4975
4976 1596 advanceframe(true);
4977
4978 // animate_combos();
4979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4980 break;
4981 1596 }
4982
4983 38 destroy_bitmap(wavebuf);
4984 38 }
4985
4986 38 void wavyin()
4987 {
4988 38 draw_screen(tmpscr);
4989 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4990
4991 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4992 38 clear_to_color(wavebuf,0);
4993 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4994
4995 static PALETTE wavepal;
4996
4997 //Breaks dark rooms.
4998 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4999 /*
5000 loadfullpal();
5001 loadlvlpal(DMaps[currdmap].color);
5002 ringcolor(false);
5003 */
5004 38 refreshpal=false;
5005 int32_t ofs;
5006 38 int32_t amplitude=8;
5007 38 int32_t wavelength=4;
5008 38 double palpos=168, palstep=4, palstop=126;
5009
5010 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5011
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
5012 {
5013
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
5014 {
5015 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5016 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5017 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5018 408576 }
5019
5020 1596 palpos-=palstep;
5021
5022
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
5023 {
5024 1596 hw_palette = &wavepal;
5025 1596 update_hw_pal = true;
5026 1596 }
5027 else
5028 {
5029 hw_palette = &RAMpal;
5030 update_hw_pal = true;
5031 }
5032
5033
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
5034 {
5035
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
5036 {
5037 68640768 ofs=0;
5038
5039
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
5040 {
5041 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5042 17160192 }
5043
5044 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5045 68640768 }
5046 268128 }
5047
5048 1596 advanceframe(true);
5049 // animate_combos();
5050
5051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
5052 break;
5053 1596 }
5054
5055 38 destroy_bitmap(wavebuf);
5056 38 }
5057
5058 1922 void blackscr(int32_t fcnt,bool showsubscr)
5059 {
5060 1922 reset_pal_cycling();
5061 1922 script_drawing_commands.Clear();
5062
5063 1922 FFCore.warpScriptCheck();
5064 1922 bool showtime = game->should_show_time();
5065
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 57590 times.
59512 while(fcnt>0)
5066 {
5067 57590 clear_bitmap(framebuf);
5068
5069
2/2
✓ Branch 0 taken 19740 times.
✓ Branch 1 taken 37850 times.
57590 if(showsubscr)
5070 {
5071 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5072
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5073 {
5074 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5075 750 }
5076 37850 }
5077
5078 57590 advanceframe(true);
5079
5080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57590 times.
57590 if(Quit)
5081 break;
5082
5083 57590 --fcnt;
5084 }
5085 1922 }
5086
5087 725 void openscreen(int32_t shape)
5088 {
5089 725 reset_pal_cycling();
5090 725 black_opening_count=0;
5091
5092
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
725 if(COOLSCROLL || shape>-1)
5093 {
5094 627 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5095 627 return;
5096 }
5097 else
5098 {
5099 98 Hero.setDontDraw(true);
5100 98 show_subscreen_dmap_dots=false;
5101 98 show_subscreen_numbers=false;
5102 // show_subscreen_items=false;
5103 98 show_subscreen_life=false;
5104 }
5105
5106 98 int32_t x=128;
5107
5108 98 FFCore.warpScriptCheck();
5109
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5110 {
5111 7840 draw_screen(tmpscr);
5112 //? draw_screen already draws the subscreen -DD
5113 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5114 7840 x=128-(((i*128/80)/8)*8);
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5117 {
5118 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5119 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5120 7840 }
5121
5122 7840 advanceframe(true);
5123
5124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5125 {
5126 break;
5127 }
5128 7840 }
5129
5130 98 Hero.setDontDraw(false);
5131 98 show_subscreen_items=true;
5132 98 show_subscreen_dmap_dots=true;
5133 725 }
5134
5135 void closescreen(int32_t shape)
5136 {
5137 reset_pal_cycling();
5138 black_opening_count=0;
5139
5140 if(COOLSCROLL || shape>-1)
5141 {
5142 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5143 return;
5144 }
5145 else
5146 {
5147 Hero.setDontDraw(true);
5148 show_subscreen_dmap_dots=false;
5149 show_subscreen_numbers=false;
5150 // show_subscreen_items=false;
5151 show_subscreen_life=false;
5152 }
5153
5154 int32_t x=128;
5155
5156 FFCore.warpScriptCheck();
5157 for(int32_t i=79; i>=0; --i)
5158 {
5159 draw_screen(tmpscr);
5160 //? draw_screen already draws the subscreen -DD
5161 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5162 x=128-(((i*128/80)/8)*8);
5163
5164 if(x>0)
5165 {
5166 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5167 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5168 }
5169
5170 advanceframe(true);
5171
5172 if(Quit)
5173 {
5174 break;
5175 }
5176 }
5177
5178 Hero.setDontDraw(false);
5179 show_subscreen_items=true;
5180 show_subscreen_dmap_dots=true;
5181 }
5182
5183 179 int32_t TriforceCount()
5184 {
5185 179 int32_t c=0;
5186
5187
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5188
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5189 1044 ++c;
5190
5191 179 return c;
5192 }
5193
5194 int32_t onCustomGame()
5195 {
5196 int32_t file = getsaveslot();
5197
5198 if(file < 0)
5199 return D_O_K;
5200
5201 bool ret = (custom_game(file)!=0);
5202 return ret ? D_CLOSE : D_O_K;
5203 }
5204
5205 int32_t onContinue()
5206 {
5207 return D_CLOSE;
5208 }
5209
5210 int32_t onEsc() // Unused?? -L
5211 {
5212 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5213 }
5214
5215 int32_t onVsync()
5216 {
5217 Throttlefps = !Throttlefps;
5218 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5219 return D_O_K;
5220 }
5221
5222 int32_t onWinPosSave()
5223 {
5224 SaveWinPos = !SaveWinPos;
5225 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5226 return D_O_K;
5227 }
5228 int32_t onIntegerScaling()
5229 {
5230 scaleForceInteger = !scaleForceInteger;
5231 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5232 return D_O_K;
5233 }
5234 int32_t onStretchGame()
5235 {
5236 stretchGame = !stretchGame;
5237 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5238 return D_O_K;
5239 }
5240
5241 int32_t onClickToFreeze()
5242 {
5243 ClickToFreeze = !ClickToFreeze;
5244 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5245 return D_O_K;
5246 }
5247
5248 int32_t OnSaveZCConfig()
5249 {
5250 if(jwin_alert3(
5251 "Save Configuration",
5252 "Are you sure that you wish to save your present configuration settings?",
5253 "This will overwrite your prior settings!",
5254 NULL,
5255 "&Yes",
5256 "&No",
5257 NULL,
5258 'y',
5259 'n',
5260 0,
5261 get_zc_font(font_lfont)) == 1)
5262 {
5263 save_game_configs();
5264 return D_O_K;
5265 }
5266 else return D_O_K;
5267 }
5268
5269 int32_t OnnClearQuestDir()
5270 {
5271 if(jwin_alert3(
5272 "Clear Current Directory Cache",
5273 "Are you sure that you wish to clear the current cached directory?",
5274 "This will default the current directory to the ROOT for this instance of ZC Player!",
5275 NULL,
5276 "&Yes",
5277 "&No",
5278 NULL,
5279 'y',
5280 'n',
5281 0,
5282 get_zc_font(font_lfont)) == 1)
5283 {
5284 zc_set_config("zeldadx","win_qst_dir","");
5285 flush_config_file();
5286 strcpy(qstdir,"");
5287 #ifdef __EMSCRIPTEN__
5288 em_sync_fs();
5289 #endif
5290 return D_O_K;
5291 }
5292 else return D_O_K;
5293 }
5294
5295
5296 int32_t onConsoleZASM()
5297 {
5298 if ( !zasm_debugger )
5299 {
5300 AlertDialog("WARNING: ZASM Debugger",
5301 "Enabling this will open the ZASM Debugger Console"
5302 "\nThis will likely grind ZC to a halt with lag."
5303 "\nTo make any use of this, it is suggested that you read"
5304 "\nthe documentation for 'void Breakpoint(char[] string);'"
5305 " in 'ZScript_Additions.txt'"
5306 "\nThis is not recommended for normal users,"
5307 " and is only intended for ZC developers,"
5308 "\nor quest developers coding directly in ZASM"
5309 "\nAre you sure that you wish to open the ZASM Debugger?",
5310 [&](bool ret,bool)
5311 {
5312 if(ret)
5313 {
5314 FFCore.ZASMPrint(true);
5315 }
5316 }).show();
5317 return D_O_K;
5318 }
5319 else
5320 {
5321 FFCore.ZASMPrint(false);
5322 return D_O_K;
5323 }
5324 }
5325
5326
5327 int32_t onConsoleZScript()
5328 {
5329 if ( !zscript_debugger )
5330 {
5331 AlertDialog("ZScript Debugger",
5332 "Enabling this will open the ZScript Debugger Console"
5333 "\nThis will display any messages logged by scripts,"
5334 " including script errors."
5335 "\nAre you sure that you wish to open the ZScript Debugger?",
5336 [&](bool ret,bool)
5337 {
5338 if(ret)
5339 {
5340 FFCore.ZScriptConsole(true);
5341 }
5342 }).show();
5343 return D_O_K;
5344 }
5345 else
5346 {
5347 FFCore.ZScriptConsole(false);
5348 return D_O_K;
5349 }
5350 }
5351
5352 int32_t onClrConsoleOnReload()
5353 {
5354 clearConsoleOnReload = !clearConsoleOnReload;
5355 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5356 return D_O_K;
5357 }
5358 int32_t onClrConsoleOnLoad()
5359 {
5360 clearConsoleOnLoad = !clearConsoleOnLoad;
5361 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5362 return D_O_K;
5363 }
5364
5365
5366 int32_t onFrameSkip()
5367 {
5368 FrameSkip = !FrameSkip;
5369 return D_O_K;
5370 }
5371
5372 int32_t onSaveDragResize()
5373 {
5374 SaveDragResize = !SaveDragResize;
5375 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5376 return D_O_K;
5377 }
5378
5379 int32_t onDragAspect()
5380 {
5381 DragAspect = !DragAspect;
5382 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5383 return D_O_K;
5384 }
5385
5386 int32_t onTransLayers()
5387 {
5388 TransLayers = !TransLayers;
5389 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5390 return D_O_K;
5391 }
5392
5393 int32_t onNESquit()
5394 {
5395 NESquit = !NESquit;
5396 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5397 return D_O_K;
5398 }
5399
5400 int32_t onVolKeys()
5401 {
5402 volkeys = !volkeys;
5403 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5404 return D_O_K;
5405 }
5406
5407 int32_t onShowFPS()
5408 {
5409 ShowFPS = !ShowFPS;
5410 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5411 return D_O_K;
5412 }
5413
5414 959607742 bool is_Fkey(int32_t k)
5415 {
5416
2/2
✓ Branch 0 taken 97587228 times.
✓ Branch 1 taken 862020514 times.
959607742 switch(k)
5417 {
5418 case KEY_F1:
5419 case KEY_F2:
5420 case KEY_F3:
5421 case KEY_F4:
5422 case KEY_F5:
5423 case KEY_F6:
5424 case KEY_F7:
5425 case KEY_F8:
5426 case KEY_F9:
5427 case KEY_F10:
5428 case KEY_F11:
5429 case KEY_F12:
5430 97587228 return true;
5431 }
5432
5433 862020514 return false;
5434 959607742 }
5435
5436 void kb_getkey(DIALOG *d);
5437
5438 //Used by all keyboard key settings dialogues.
5439 void kb_clearjoystick(DIALOG *d)
5440 {
5441 d->flags|=D_SELECTED;
5442
5443 jwin_button_proc(MSG_DRAW,d,0);
5444 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5445 // text_mode(vc(11));
5446 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5447 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5448
5449 update_hw_screen(true);
5450
5451 clear_keybuf();
5452 int32_t k = next_press_key();
5453 clear_keybuf();
5454
5455 //shnarf
5456 //47=f1
5457 //59=esc
5458 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5459 // *((int32_t*)d->dp3) = k;
5460 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5461
5462
5463 d->flags&=~D_SELECTED;
5464 }
5465
5466 //Clears key to 0.
5467 //Used by all keyboard key settings dialogues.
5468 void kb_clearkey(DIALOG *d);
5469
5470 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5471 {
5472 switch(msg)
5473 {
5474 case MSG_KEY:
5475 case MSG_CLICK:
5476
5477 kb_clearjoystick(d);
5478
5479 while(gui_mouse_b())
5480 {
5481 clear_keybuf();
5482 rest(1);
5483 }
5484
5485 return D_REDRAW;
5486 }
5487
5488 return jwin_button_proc(msg,d,c);
5489 }
5490
5491 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5492 //Only used in keyboard settings dialogues to clear keys.
5493 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5494
5495 void j_getbtn(DIALOG *d)
5496 {
5497 d->flags|=D_SELECTED;
5498 jwin_button_proc(MSG_DRAW,d,0);
5499 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5500 // text_mode(vc(11));
5501 int32_t y = gui_bmp->h/2 - 12;
5502 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5503 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5504 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5505
5506 update_hw_screen(true);
5507
5508 int32_t b = next_press_btn();
5509
5510 if(b>=0)
5511 *((int32_t*)d->dp3) = b;
5512
5513 d->flags&=~D_SELECTED;
5514
5515 if (player)
5516 player->joy_on = TRUE;
5517 }
5518
5519 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5520 {
5521 switch(msg)
5522 {
5523 case MSG_KEY:
5524 case MSG_CLICK:
5525
5526 j_getbtn(d);
5527
5528 while(gui_mouse_b()) {
5529 rest(1);
5530 clear_keybuf();
5531 }
5532
5533 return D_REDRAW;
5534 }
5535
5536 return jwin_button_proc(msg,d,c);
5537 }
5538
5539 //shnarf
5540 extern const char *key_str[];
5541 std::string get_keystr(int key);
5542
5543 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5544 //extern int32_t zcmusic_bufsz;
5545
5546 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5547 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5548
5549 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5550 {
5551 //these are here to bypass compiler warnings about unused arguments
5552 c=c;
5553
5554 if(msg==MSG_DRAW)
5555 {
5556 switch(d->w)
5557 {
5558 case 0:
5559 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5560 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5561 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5562 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5563 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5564 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5565 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5566 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5567 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5568 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5569 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5570 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5571 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5572 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5573 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5574 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5575 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5576 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5577 break;
5578
5579 case 1:
5580 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5581 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5582 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5583 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5584 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5585 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5586 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5587 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5588 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5589 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5590 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5591 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5592 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5593 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5594 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5595 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5596 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5597 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5598 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5599 break;
5600
5601 case 2:
5602 sprintf(str_a," %3d",midi_volume);
5603 sprintf(str_b," %3d",digi_volume);
5604 sprintf(str_l," %3d",emusic_volume);
5605 sprintf(str_m," %3dKB",zcmusic_bufsz);
5606 sprintf(str_r," %3d",sfx_volume);
5607 strcpy(str_s,pan_str[pan_style]);
5608 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5609 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5610 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5611 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5612 break;
5613 }
5614 }
5615
5616 return D_O_K;
5617 }
5618
5619 int32_t set_vol(void *dp3, int32_t d2)
5620 {
5621 switch(((int32_t*)dp3)[0])
5622 {
5623 case 0:
5624 midi_volume = zc_min(d2<<3,255);
5625 break;
5626
5627 case 1:
5628 digi_volume = zc_min(d2<<3,255);
5629 break;
5630
5631 case 2:
5632 emusic_volume = zc_min(d2<<3,255);
5633 break;
5634
5635 case 3:
5636 sfx_volume = zc_min(d2<<3,255);
5637 break;
5638 }
5639
5640 // text_mode(vc(11));
5641 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5642 return D_O_K;
5643 }
5644
5645 int32_t set_pan(void *dp3, int32_t d2)
5646 {
5647 pan_style = vbound(d2,0,3);
5648 // text_mode(vc(11));
5649 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5650 return D_O_K;
5651 }
5652
5653 int32_t set_buf(void *dp3, int32_t d2)
5654 {
5655 // text_mode(vc(11));
5656 zcmusic_bufsz = d2 + 1;
5657 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5658 return D_O_K;
5659 }
5660
5661 static int32_t gamepad_btn_list[] =
5662 {
5663 6,
5664 7,8,9,10,11,12,13,14,15,16,17,
5665 18,19,20,21,22,23,24,25,26,27,28,
5666 29,30,31,32,33,34,35,36,37,38,39,
5667 -1
5668 };
5669
5670 static int32_t gamepad_dirs_list[] =
5671 {
5672 40,41,42,43,
5673 44,45,46,47,
5674 48,49,50,51,
5675 52,53,54,55,
5676 56,
5677 -1
5678 };
5679
5680 static TABPANEL gamepad_tabs[] =
5681 {
5682 // (text)
5683 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5684 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5685 { NULL, 0, NULL, 0, NULL }
5686 };
5687
5688 static DIALOG gamepad_dlg[] =
5689 {
5690 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5691 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5692 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5693 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5694 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5695 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5696 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5697 // 6
5698 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5699 // 7
5700 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5701 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5702 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5703 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5704 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5705 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5706 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5707 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5708 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5709 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5710 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5711 // 18
5712 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5713 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5714 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5715 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5716 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5717 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5718 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5719 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5720 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5721 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5722 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5723 // 29
5724 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5725 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5726 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5727 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5728 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5729 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5730 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5731 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5732 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5733 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5734 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5735 // 40
5736 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5737 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5738 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5739 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5740 // 44
5741 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5742 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5743 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5744 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5745 // 48
5746 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5747 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5748 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5749 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5750 // 52
5751 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5752 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5753 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5754 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5755 // 56
5756 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5757 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5758 };
5759
5760 static int32_t keyboard_keys_list[] =
5761 {
5762 6,7,8,9,10,
5763 11,12,13,14,15,16,17,18,19,20,
5764 21,22,23,24,25,26,27,28,29,30,
5765 31,32,33,34,35,36,37,38,39,40,
5766 -1
5767 };
5768
5769 static int32_t keyboard_dirs_list[] =
5770 {
5771 41,42,43,44,
5772 45,46,47,48,
5773 49,50,51,52,
5774 53,54,55,56,
5775 -1
5776 };
5777
5778 static int32_t keyboard_mods_list[] =
5779 {
5780 57,58,59,60,
5781 61,62,63,64,
5782 65,66,67,68,
5783 69,70,71,72,
5784 -1
5785 };
5786
5787 static TABPANEL keyboard_control_tabs[] =
5788 {
5789 // (text)
5790 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5791 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5792 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5793 { NULL, 0, NULL, 0, NULL }
5794 };
5795
5796 static DIALOG keyboard_control_dlg[] =
5797 {
5798 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5799 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5800 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5801 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5802 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5803 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5804 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5805 // Keys
5806 // 6
5807 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5809 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5810 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5811 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5812 // 11
5813 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5814 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5815 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5816 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5817 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5818 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5819 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5820 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5821 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5822 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5823 // 21
5824 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5825 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5826 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5827 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5828 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5829 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5830 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5831 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5832 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5833 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5834 // 31
5835 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5836 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5837 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5838 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5839 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5840 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5841 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5842 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5843 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5844 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5845 // Dirs
5846 // 41
5847 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5848 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5849 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5850 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5851 // 45
5852 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5853 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5854 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5855 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5856 // 49
5857 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5858 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5859 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5860 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5861 // 53
5862 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5863 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5864 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5865 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5866 // Mods
5867 // 57
5868 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5869 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5870 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5871 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5872 // 61
5873 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5874 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5875 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5876 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5877 // 65
5878 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5879 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5880 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5881 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5882 // 69
5883 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5884 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5885 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5886 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5887 // 73
5888 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5889 };
5890
5891 /*
5892 int32_t midi_dp[3] = {0,147,104};
5893 int32_t digi_dp[3] = {1,147,120};
5894 int32_t pan_dp[3] = {0,147,136};
5895 int32_t buf_dp[3] = {0,147,152};
5896 */
5897 int32_t midi_dp[3] = {0,0,0};
5898 int32_t digi_dp[3] = {1,0,0};
5899 int32_t emus_dp[3] = {2,0,0};
5900 int32_t buf_dp[3] = {0,0,0};
5901 int32_t sfx_dp[3] = {3,0,0};
5902 int32_t pan_dp[3] = {0,0,0};
5903
5904 static DIALOG sound_dlg[] =
5905 {
5906 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5907 33 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5908 33 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5909 33 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5910 33 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5911 33 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 33 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5913 33 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5914 33 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5915 33 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5916 33 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5917 // 10
5918 33 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5919 33 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5920 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5923 33 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5924 33 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5925 33 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5926 33 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5927 33 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5928 //20
5929 33 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5930 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5931 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 33 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5934 33 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5935 33 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5936 33 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5937 33 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5938 33 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5939 //30
5940 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5941 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 33 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5943 33 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 };
5945
5946 char zc_builddate[80];
5947 char zc_aboutstr[80];
5948
5949 static DIALOG about_dlg[] =
5950 {
5951 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5952 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5953 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5954 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5955 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5956 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5957 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5958 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5959 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5960 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5961 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5962 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5963 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5964 };
5965
5966
5967 static DIALOG quest_dlg[] =
5968 {
5969 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5970 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5971 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5972 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5973 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5974 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5975 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5976 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5977 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5978 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5979 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5980 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5981 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5982 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5983 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5984 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5985 };
5986
5987 static DIALOG triforce_dlg[] =
5988 {
5989 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5990 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5991 // 1
5992 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5993 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5994 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5995 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5996 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5997 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5998 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5999 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6000 // 9
6001 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6002 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6003 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6004 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6005 };
6006
6007 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6008 {
6009 go();
6010 int32_t ret=0;
6011 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6012 comeback();
6013 return ret != 0;
6014 }
6015
6016
6017 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6018 {
6019 if(def!=modulepath)
6020 strcpy(modulepath,def);
6021
6022 if(!usefilename)
6023 {
6024 int32_t i=(int32_t)strlen(modulepath);
6025
6026 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6027 modulepath[i--]=0;
6028 }
6029
6030 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6031 int32_t ret=0;
6032 int32_t sel=0;
6033
6034 if(list==NULL)
6035 {
6036 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6037 }
6038 else
6039 {
6040 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6041 }
6042
6043 return ret!=0;
6044 }
6045
6046 //The Dialogue that loads a ZMOD Module File
6047 int32_t zc_load_zmod_module_file()
6048 {
6049 if ( Playing )
6050 {
6051 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6052 return -1;
6053 }
6054 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6055 return D_CLOSE;
6056
6057 FILE *tempmodule = fopen(modulepath,"r");
6058
6059 if(tempmodule == NULL)
6060 {
6061 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6062 return -1;
6063 }
6064
6065
6066 //Set the module path:
6067 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6068 strcpy(moduledata.module_name, modulepath);
6069 al_trace("New Module Path is: %s \n", moduledata.module_name);
6070 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6071 zcm.init(true); //Load the module values.
6072 moduledata.refresh_title_screen = 1;
6073 // refresh_select_screen = 1;
6074 build_biic_list();
6075 return D_O_K;
6076 }
6077
6078 static DIALOG module_info_dlg[] =
6079 {
6080 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6081
6082
6083 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6084 //1
6085 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6086 //2
6087 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6088 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6089 //4
6090 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6091 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6092 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6093 //7
6094
6095 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6096 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6097 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6098 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6099 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6100 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6101 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6102 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6103 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6104
6105 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6106 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6107 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6108 };
6109
6110 void about_zcplayer_module(const char *prompt,int32_t initialval)
6111 {
6112
6113 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6114 if ( moduledata.moduletitle[0] != 0 )
6115 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6116
6117 if ( moduledata.moduleauthor[0] != 0 )
6118 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6119
6120 if ( moduledata.moduleinfo0[0] != 0 )
6121 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6122 if ( moduledata.moduleinfo1[0] != 0 )
6123 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6124 if ( moduledata.moduleinfo2[0] != 0 )
6125 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6126 if ( moduledata.moduleinfo3[0] != 0 )
6127 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6128 if ( moduledata.moduleinfo4[0] != 0 )
6129 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6130
6131 char module_date[255];
6132 memset(module_date, 0, sizeof(module_date));
6133 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6134 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6135
6136
6137
6138 char module_vers[255];
6139 memset(module_vers, 0, sizeof(module_vers));
6140 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6141
6142
6143 //sprintf(tilecount,"%d",1);
6144
6145 char module_build[255];
6146 memset(module_build, 0, sizeof(module_build));
6147 if ( moduledata.modbeta )
6148 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6149 else
6150 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6151
6152 module_info_dlg[12].dp = (char*)module_date;
6153 module_info_dlg[13].dp = (char*)module_vers;
6154 module_info_dlg[14].dp = (char*)module_build;
6155
6156 large_dialog(module_info_dlg);
6157
6158 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6159 jwin_center_dialog(module_info_dlg);
6160
6161
6162 }
6163
6164 int32_t onAbout_ZCP_Module()
6165 {
6166 about_zcplayer_module("About Module (.zmod)", 0);
6167 return D_O_K;
6168 }
6169
6170 //New Modules Menu for 2.55+
6171 static MENU zcmodule_menu[] =
6172 {
6173 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6174 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6175
6176 { NULL, NULL, NULL, 0, NULL }
6177 };
6178
6179 int32_t onToggleRecordingNewSaves()
6180 {
6181 if (zc_get_config("zeldadx", "replay_new_saves", false))
6182 {
6183 zc_set_config("zeldadx", "replay_new_saves", false);
6184 }
6185 else
6186 {
6187 zc_set_config("zeldadx", "replay_new_saves", true);
6188 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6189 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6190 }
6191 return D_O_K;
6192 }
6193
6194 int32_t onToggleSnapshotAllFrames()
6195 {
6196 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6197 return D_O_K;
6198 }
6199
6200 int32_t onStopReplayOrRecord()
6201 {
6202 if (replay_is_replaying())
6203 {
6204 replay_quit();
6205 }
6206 else if (replay_get_mode() == ReplayMode::Record)
6207 {
6208 if (!replay_get_meta_bool("test_mode"))
6209 {
6210 jwin_alert("Recording", "You cannot stop recording a save file.",
6211 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6212 return D_CLOSE;
6213 }
6214
6215 if (jwin_alert("Stop Recording",
6216 "Save replay to disk and stop recording?",
6217 "This will stop the recording.",
6218 NULL,
6219 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6220 return D_CLOSE;
6221
6222 replay_save();
6223 replay_stop();
6224 }
6225 return D_O_K;
6226 }
6227
6228 static int32_t handle_on_load_replay(ReplayMode mode)
6229 {
6230 if (Playing)
6231 {
6232 if (jwin_alert("Replay - Warning!",
6233 "Loading a replay will exit the current game.",
6234 "All unsaved progress will be lost.",
6235 "Do you wish to continue?",
6236 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6237 return D_CLOSE;
6238 }
6239
6240 std::string mode_string = replay_mode_to_string(mode);
6241 mode_string[0] = std::toupper(mode_string[0]);
6242
6243 std::string line_1 = "Select a replay file to play back.";
6244 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6245 std::string line_3 = "You can stop the replay and take over manually any time.";
6246 if (mode == ReplayMode::Update)
6247 {
6248 line_1 = "Select a replay file to update.";
6249 line_2 = "WARNING: be sure to back up the zplay file";
6250 line_3 = "and verify that the updated replay works as expected!";
6251 }
6252
6253 if (jwin_alert(mode_string.c_str(),
6254 line_1.c_str(),
6255 line_2.c_str(),
6256 line_3.c_str(),
6257 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6258 {
6259 char replay_path[2048];
6260 strcpy(replay_path, "replays/");
6261 if (jwin_file_select_ex(
6262 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6263 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6264 return D_CLOSE;
6265
6266 replay_quit();
6267 load_replay_file_deferred(mode, replay_path);
6268 Quit = qRESET;
6269 return D_CLOSE;
6270 }
6271 return D_O_K;
6272 }
6273
6274 int32_t onLoadReplay()
6275 {
6276 return handle_on_load_replay(ReplayMode::Replay);
6277 }
6278
6279 int32_t onLoadReplayAssert()
6280 {
6281 return handle_on_load_replay(ReplayMode::Assert);
6282 }
6283
6284 int32_t onLoadReplayUpdate()
6285 {
6286 return handle_on_load_replay(ReplayMode::Update);
6287 }
6288
6289 int32_t onSaveReplay()
6290 {
6291 if (replay_get_mode() == ReplayMode::Record)
6292 {
6293 if (!replay_get_meta_bool("test_mode"))
6294 {
6295 if (jwin_alert("Save Replay",
6296 "This will save a copy of the replay up to this point.",
6297 "The official replay file will be untouched.",
6298 "Do you wish to continue?",
6299 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6300 return D_CLOSE;
6301
6302 char replay_path[2048];
6303 strcpy(replay_path, replay_get_replay_path().string().c_str());
6304 if (jwin_file_select_ex(
6305 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6306 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6307 return D_CLOSE;
6308
6309 if (fileexists(replay_path))
6310 {
6311 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6312 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6313 return D_CLOSE;
6314 }
6315
6316 replay_save(replay_path);
6317 }
6318 else
6319 {
6320 replay_save();
6321 }
6322 }
6323 return D_O_K;
6324 }
6325
6326 static MENU replay_menu[] =
6327 {
6328 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6329 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6330 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6331 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6332 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6333 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6334 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6335
6336 { NULL, NULL, NULL, 0, NULL }
6337 };
6338
6339 static DIALOG credits_dlg[] =
6340 {
6341 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6342 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6343 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6344 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6345 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6346 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6347 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6348 };
6349
6350 33 static ListData dmap_list(dmaplist, &font);
6351
6352 static DIALOG goto_dlg[] =
6353 {
6354 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6355 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6356 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6357 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6358 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6359 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6360 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6361 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6362 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6363 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6364 };
6365
6366 int32_t onGoTo()
6367 {
6368 bool music = false;
6369 music = music;
6370 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6371
6372 goto_dlg[0].dp2=get_zc_font(font_lfont);
6373 goto_dlg[4].d2=cheat_goto_dmap;
6374 goto_dlg[6].dp=cheat_goto_screen_str;
6375
6376 clear_keybuf();
6377
6378 large_dialog(goto_dlg);
6379
6380 if(zc_popup_dialog(goto_dlg,4)==1)
6381 {
6382 // dmap, screen
6383 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6384 };
6385
6386 return D_O_K;
6387 }
6388
6389 int32_t onGoToComplete()
6390 {
6391 if(!Playing)
6392 {
6393 return D_O_K;
6394 }
6395
6396 system_pal();
6397 music_pause();
6398 pause_all_sfx();
6399 sys_mouse();
6400 onGoTo();
6401 eat_buttons();
6402
6403 zc_readrawkey(KEY_ESC);
6404
6405 game_mouse();
6406 game_pal();
6407 music_resume();
6408 resume_all_sfx();
6409 return D_O_K;
6410 }
6411
6412 int32_t onCredits()
6413 {
6414 go();
6415
6416 BITMAP *win = create_bitmap_ex(8,222,110);
6417
6418 if(!win)
6419 return D_O_K;
6420
6421 int32_t c=0;
6422 int32_t l=0;
6423 int32_t ol=-1;
6424 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6425 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6426 PALETTE tmppal;
6427
6428 rti_gui.transparency_index = 1;
6429
6430 clear_to_color(win, rti_gui.transparency_index);
6431 draw_rle_sprite(win,rle,0,0);
6432 credits_dlg[0].dp2=get_zc_font(font_lfont);
6433 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6434 credits_dlg[2].dp = win;
6435
6436 zc_set_palette_range(black_palette,0,127,false);
6437
6438 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6439
6440 BITMAP* old_screen = screen;
6441 BITMAP* gui_bmp = zc_get_gui_bmp();
6442 ASSERT(gui_bmp);
6443 clear_to_color(gui_bmp, rti_gui.transparency_index);
6444 screen = gui_bmp;
6445
6446 while(update_dialog(p))
6447 {
6448 throttleFPS();
6449 ++c;
6450 l = zc_max((c>>1)-30,0);
6451
6452 if(l > rle->h)
6453 l = c = 0;
6454
6455 if(l > rle->h - 112)
6456 l = rle->h - 112;
6457
6458 clear_bitmap(win);
6459 draw_rle_sprite(win,rle,0,0-l);
6460
6461 if(c<=64)
6462 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6463
6464 zc_set_palette_range(tmppal,0,127,false);
6465
6466 if(l!=ol)
6467 {
6468 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6469 SCRFIX();
6470 ol=l;
6471 }
6472
6473 update_hw_screen();
6474 }
6475
6476 screen = old_screen;
6477 system_pal();
6478
6479 shutdown_dialog(p);
6480 destroy_bitmap(win);
6481 //comeback();
6482
6483 rti_gui.transparency_index = 0;
6484 clear_to_color(gui_bmp, rti_gui.transparency_index);
6485
6486 return D_O_K;
6487 }
6488
6489 const char *midilist(int32_t index, int32_t *list_size)
6490 {
6491 if(index<0)
6492 {
6493 *list_size=0;
6494
6495 for(int32_t i=0; i<MAXMIDIS; i++)
6496 if(tunes[i].data)
6497 ++(*list_size);
6498
6499 return NULL;
6500 }
6501
6502 int32_t i=0,m=0;
6503
6504 while(m<=index && i<=MAXMIDIS)
6505 {
6506 if(tunes[i].data)
6507 ++m;
6508
6509 ++i;
6510 }
6511
6512 --i;
6513
6514 if(i==MAXMIDIS && m<index)
6515 return "(null)";
6516
6517 return tunes[i].title;
6518 }
6519
6520 /* ------- MIDI info stuff -------- */
6521
6522 char *text;
6523 midi_info *zmi;
6524 bool dialog_running;
6525 bool listening;
6526
6527 void get_info(int32_t index);
6528
6529 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6530 {
6531 int32_t d2 = d->d2;
6532 int32_t ret = jwin_droplist_proc(msg,d,c);
6533
6534 if(d2!=d->d2)
6535 {
6536 get_info(d->d2);
6537 }
6538
6539 return ret;
6540 }
6541
6542 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6543 {
6544 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6545
6546 int32_t ret = jwin_button_proc(msg,d,c);
6547
6548 if(ret == D_CLOSE)
6549 {
6550 // get current midi index
6551 int32_t index = (d+(d->d1))->d2;
6552 int32_t i=0, m=0;
6553
6554 while(m<=index && i<=MAXMIDIS)
6555 {
6556 if(tunes[i].data)
6557 ++m;
6558
6559 ++i;
6560 }
6561
6562 --i;
6563 jukebox(i);
6564 listening = true;
6565 ret = D_O_K;
6566 }
6567
6568 return ret;
6569 }
6570
6571 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6572 {
6573 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6574
6575 int32_t ret = jwin_button_proc(msg,d,c);
6576
6577 if(ret == D_CLOSE)
6578 {
6579 // get current midi index
6580 int32_t index = (d+(d->d1))->d2;
6581 int32_t i=0, m=0;
6582
6583 while(m<=index && i<=MAXMIDIS)
6584 {
6585 if(tunes[i].data)
6586 ++m;
6587
6588 ++i;
6589 }
6590
6591 --i;
6592
6593 // get file name
6594
6595 int32_t sel=0;
6596 //struct ffblk f;
6597 char title[40] = "Save MIDI: ";
6598 char fname[2048];
6599 memset(fname,0,2048);
6600 static EXT_LIST list[] =
6601 {
6602 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6603 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6604 { NULL, NULL }
6605 };
6606
6607 strcpy(title+11, tunes[i].title);
6608 title[39] = '\0';
6609
6610 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6611 goto done;
6612
6613 if(exists(fname))
6614 {
6615 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6616 goto done;
6617 }
6618
6619 // save midi i
6620
6621 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6622 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6623
6624 done:
6625 chop_path(fname);
6626 ret = D_REDRAW;
6627 }
6628
6629 return ret;
6630 }
6631
6632 33 static ListData midi_list(midilist, &font);
6633
6634 static DIALOG midi_dlg[] =
6635 {
6636 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6637 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6638 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6639 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6640 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6641 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6642 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6643 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6644 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6645 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6646 };
6647
6648 void get_info(int32_t index)
6649 {
6650 int32_t i=0, m=0;
6651
6652 while(m<=index && i<=MAXMIDIS)
6653 {
6654 if(tunes[i].data)
6655 ++m;
6656
6657 ++i;
6658 }
6659
6660 --i;
6661
6662 if(i==MAXMIDIS && m<index)
6663 strcpy(text,"(null)");
6664 else
6665 {
6666 get_midi_info((MIDI*)tunes[i].data,zmi);
6667 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6668 }
6669
6670 midi_dlg[0].dp2=get_zc_font(font_lfont);
6671 midi_dlg[3].dp = text;
6672 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6673 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6674
6675 if(dialog_running)
6676 {
6677 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6678 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6679 }
6680 }
6681
6682 int32_t onMIDICredits()
6683 {
6684 text = (char*)malloc(4096);
6685 zmi = (midi_info*)malloc(sizeof(midi_info));
6686
6687 if(!text || !zmi)
6688 {
6689 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6690 return D_O_K;
6691 }
6692
6693 bool do_pause_midi = midi_pos >= 0 && currmidi;
6694 auto restore_midi = currmidi;
6695 if(do_pause_midi)
6696 {
6697 paused_midi_pos = midi_pos;
6698 stop_midi();
6699 midi_paused=true;
6700 midi_suspended = midissuspHALTED;
6701 }
6702
6703 midi_dlg[0].dp2=get_zc_font(font_lfont);
6704 midi_dlg[2].d1 = 0;
6705 midi_dlg[2].d2 = 0;
6706 midi_dlg[4].flags = D_EXIT;
6707 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6708
6709 listening = false;
6710 dialog_running=false;
6711 get_info(0);
6712
6713 dialog_running=true;
6714
6715 large_dialog(midi_dlg);
6716
6717 zc_popup_dialog(midi_dlg,0);
6718 dialog_running=false;
6719
6720 if(listening)
6721 music_stop();
6722
6723 if(do_pause_midi)
6724 {
6725 midi_suspended = midissuspRESUME;
6726 currmidi = restore_midi;
6727 midi_pos = paused_midi_pos;
6728 }
6729
6730 if(text) free(text);
6731 if(zmi) free(zmi);
6732 return D_O_K;
6733 }
6734
6735 int32_t onAbout()
6736 {
6737 char buf1[80]={0};
6738 std::ostringstream oss;
6739 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6740 oss << buf1 << '\n';
6741 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6742 oss << buf1 << '\n';
6743 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6744 oss << buf1 << '\n';
6745 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6746 oss << buf1 << '\n';
6747 sprintf(buf1, "Tag: %s", getReleaseTag());
6748 oss << buf1 << '\n';
6749
6750 InfoDialog("About ZC", oss.str()).show();
6751 return D_O_K;
6752 }
6753
6754 int32_t onQuest()
6755 {
6756 char fname[100];
6757 strcpy(fname, get_filename(qstpath));
6758 quest_dlg[0].dp2=get_zc_font(font_lfont);
6759 quest_dlg[1].dp = fname;
6760
6761 if(QHeader.quest_number==0)
6762 sprintf(str_a,"Custom");
6763 else
6764 sprintf(str_a,"%d",QHeader.quest_number);
6765
6766 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6767
6768 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6769 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6770
6771 large_dialog(quest_dlg);
6772
6773 zc_popup_dialog(quest_dlg, 0);
6774 return D_O_K;
6775 }
6776
6777 void call_vidmode_dlg();
6778 int32_t onVidMode()
6779 {
6780 call_vidmode_dlg();
6781 return D_O_K;
6782 }
6783
6784 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6785 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6786 //Added an extra statement, so that if the key is cleared to 0, the cleared
6787 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6788
6789 void load_ukeys(int32_t* arr)
6790 {
6791 arr[ukey_a] = Akey;
6792 arr[ukey_b] = Bkey;
6793 arr[ukey_s] = Skey;
6794 arr[ukey_l] = Lkey;
6795 arr[ukey_r] = Rkey;
6796 arr[ukey_p] = Pkey;
6797 arr[ukey_ex1] = Exkey1;
6798 arr[ukey_ex2] = Exkey2;
6799 arr[ukey_ex3] = Exkey3;
6800 arr[ukey_ex4] = Exkey4;
6801 arr[ukey_du] = DUkey;
6802 arr[ukey_dd] = DDkey;
6803 arr[ukey_dl] = DLkey;
6804 arr[ukey_dr] = DRkey;
6805 arr[ukey_mod1a] = cheat_modifier_keys[0];
6806 arr[ukey_mod1b] = cheat_modifier_keys[1];
6807 arr[ukey_mod2a] = cheat_modifier_keys[2];
6808 arr[ukey_mod2b] = cheat_modifier_keys[3];
6809 };
6810
6811 static const char* ukey_names[] = {
6812 "A", "B", "Start", "L", "R", "Map",
6813 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6814 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6815 "Cheat Mod R1", "Cheat Mod R2",
6816 };
6817 std::string get_ukey_name(int32_t k)
6818 {
6819 if (k < num_ukey) return ukey_names[k];
6820 return "";
6821 }
6822
6823 int32_t onKeyboard()
6824 {
6825 int32_t a = Akey;
6826 int32_t b = Bkey;
6827 int32_t s = Skey;
6828 int32_t l = Lkey;
6829 int32_t r = Rkey;
6830 int32_t p = Pkey;
6831 int32_t ex1 = Exkey1;
6832 int32_t ex2 = Exkey2;
6833 int32_t ex3 = Exkey3;
6834 int32_t ex4 = Exkey4;
6835 int32_t du = DUkey;
6836 int32_t dd = DDkey;
6837 int32_t dl = DLkey;
6838 int32_t dr = DRkey;
6839 int32_t mod1a = cheat_modifier_keys[0];
6840 int32_t mod1b = cheat_modifier_keys[1];
6841 int32_t mod2a = cheat_modifier_keys[2];
6842 int32_t mod2b = cheat_modifier_keys[3];
6843 bool done=false;
6844 int32_t ret;
6845
6846 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6847
6848 large_dialog(keyboard_control_dlg);
6849
6850 while(!done)
6851 {
6852 ret = zc_popup_dialog(keyboard_control_dlg,3);
6853
6854 if(ret==3) // OK
6855 {
6856 int32_t ukeys[num_ukey];
6857 load_ukeys(ukeys);
6858 std::vector<std::string> uniqueError;
6859 for(int32_t q = 0; q < num_ukey; ++q)
6860 {
6861 for(int32_t p = q+1; p < num_ukey; ++p)
6862 {
6863 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6864 {
6865 char buf[64];
6866 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6867 std::string str(buf);
6868 uniqueError.push_back(str);
6869 }
6870 }
6871 }
6872 if(uniqueError.size() == 0)
6873 {
6874 done = true;
6875 save_control_configs(true);
6876 }
6877 else
6878 {
6879 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6880 box_out("Cannot have duplicate keybinds!"); box_eol();
6881 for(std::vector<std::string>::iterator it = uniqueError.begin();
6882 it != uniqueError.end(); ++it)
6883 {
6884 box_out((*it).c_str()); box_eol();
6885 }
6886 box_end(true);
6887 }
6888 }
6889 else // Cancel
6890 {
6891 Akey = a;
6892 Bkey = b;
6893 Skey = s;
6894 Lkey = l;
6895 Rkey = r;
6896 Pkey = p;
6897 Exkey1 = ex1;
6898 Exkey2 = ex2;
6899 Exkey3 = ex3;
6900 Exkey4 = ex4;
6901 DUkey = du;
6902 DDkey = dd;
6903 DLkey = dl;
6904 DRkey = dr;
6905 cheat_modifier_keys[0] = mod1a;
6906 cheat_modifier_keys[1] = mod1b;
6907 cheat_modifier_keys[2] = mod2a;
6908 cheat_modifier_keys[3] = mod2b;
6909
6910 done=true;
6911 }
6912
6913 rest(1);
6914 }
6915
6916 return D_O_K;
6917 }
6918
6919 int32_t onGamepad()
6920 {
6921 int32_t a = Abtn;
6922 int32_t b = Bbtn;
6923 int32_t s = Sbtn;
6924 int32_t l = Lbtn;
6925 int32_t r = Rbtn;
6926 int32_t m = Mbtn;
6927 int32_t p = Pbtn;
6928 int32_t ex1 = Exbtn1;
6929 int32_t ex2 = Exbtn2;
6930 int32_t ex3 = Exbtn3;
6931 int32_t ex4 = Exbtn4;
6932 int32_t up = DUbtn;
6933 int32_t down = DDbtn;
6934 int32_t left = DLbtn;
6935 int32_t right = DRbtn;
6936
6937 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6938 if(analog_movement)
6939 gamepad_dlg[56].flags|=D_SELECTED;
6940 else
6941 gamepad_dlg[56].flags&=~D_SELECTED;
6942
6943 large_dialog(gamepad_dlg);
6944
6945 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6946
6947 if(ret == 4) //OK
6948 {
6949 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6950 save_control_configs(false);
6951 }
6952 else //Cancel
6953 {
6954 Abtn = a;
6955 Bbtn = b;
6956 Sbtn = s;
6957 Lbtn = l;
6958 Rbtn = r;
6959 Mbtn = m;
6960 Pbtn = p;
6961 Exbtn1 = ex1;
6962 Exbtn2 = ex2;
6963 Exbtn3 = ex3;
6964 Exbtn4 = ex4;
6965 DUbtn = up;
6966 DDbtn = down;
6967 DLbtn = left;
6968 DRbtn = right;
6969 }
6970
6971 return D_O_K;
6972 }
6973
6974 int32_t onCheatKeys()
6975 {
6976 int32_t oldcheats[Cheat::Last][2];
6977 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6978
6979 bool done=false;
6980
6981 while(!done)
6982 {
6983 bool confirm = false;
6984 CheatKeysDialog(&confirm).show();
6985 if(confirm) // OK
6986 {
6987 std::vector<std::string> uniqueError;
6988 char buf[512];
6989 for(size_t q = 1; q < Cheat::Last; ++q)
6990 {
6991 if(cheatkeys[q][1] && !cheatkeys[q][0])
6992 {
6993 cheatkeys[q][0] = cheatkeys[q][1];
6994 cheatkeys[q][1] = 0;
6995 }
6996 }
6997 for(size_t q = 1; q < Cheat::Last; ++q)
6998 {
6999 if(!bindable_cheat((Cheat)q)) continue;
7000 for(size_t p = q+1; p < Cheat::Last; ++p)
7001 {
7002 if(!bindable_cheat((Cheat)p)) continue;
7003 for(size_t q2 = 0; q2 <= 1; ++q2)
7004 for(size_t p2 = 0; p2 <= 1; ++p2)
7005 {
7006 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
7007 {
7008 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
7009 cheat_to_string((Cheat)q), q2?"Alt":"Main",
7010 cheat_to_string((Cheat)p), p2?"Alt":"Main",
7011 get_keystr(cheatkeys[q][q2])));
7012 }
7013 }
7014 }
7015 }
7016 if(uniqueError.size() == 0)
7017 {
7018 done = true;
7019 save_cheatkeys();
7020 }
7021 else
7022 {
7023 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7024 box_out("Cannot have duplicate keybinds!"); box_eol();
7025 for(std::vector<std::string>::iterator it = uniqueError.begin();
7026 it != uniqueError.end(); ++it)
7027 {
7028 box_out((*it).c_str()); box_eol();
7029 }
7030 box_end(true);
7031 }
7032 }
7033 else // Cancel
7034 {
7035 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7036 done=true;
7037 }
7038 rest(1);
7039 }
7040
7041 return D_O_K;
7042 }
7043
7044 int32_t onSound()
7045 {
7046 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7047 {
7048 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7049 }
7050 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7051 {
7052 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7053 }
7054 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7055 {
7056 emusic_volume = (int32_t)FFCore.usr_music_volume;
7057 }
7058 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7059 {
7060 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7061 }
7062 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7063 {
7064 pan_style = (int32_t)FFCore.usr_panstyle;
7065 }
7066
7067 int32_t m = midi_volume;
7068 int32_t d = digi_volume;
7069 int32_t e = emusic_volume;
7070 int32_t b = zcmusic_bufsz;
7071 int32_t s = sfx_volume;
7072 int32_t p = pan_style;
7073 pan_style = vbound(pan_style,0,3);
7074
7075 sound_dlg[0].dp2=get_zc_font(font_lfont);
7076
7077 large_dialog(sound_dlg);
7078
7079 midi_dp[1] = sound_dlg[6].x;
7080 midi_dp[2] = sound_dlg[6].y;
7081 digi_dp[1] = sound_dlg[7].x;
7082 digi_dp[2] = sound_dlg[7].y;
7083 emus_dp[1] = sound_dlg[8].x;
7084 emus_dp[2] = sound_dlg[8].y;
7085 buf_dp[1] = sound_dlg[9].x;
7086 buf_dp[2] = sound_dlg[9].y;
7087 sfx_dp[1] = sound_dlg[10].x;
7088 sfx_dp[2] = sound_dlg[10].y;
7089 pan_dp[1] = sound_dlg[11].x;
7090 pan_dp[2] = sound_dlg[11].y;
7091 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7092 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7093 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7094 sound_dlg[18].d2 = zcmusic_bufsz;
7095 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7096 sound_dlg[20].d2 = pan_style;
7097
7098 int32_t ret = zc_popup_dialog(sound_dlg,1);
7099
7100 if(ret==2)
7101 {
7102 master_volume(digi_volume,midi_volume);
7103
7104 for(int32_t i=0; i<WAV_COUNT; ++i)
7105 {
7106 //allegro assertion fails when passing in -1 as voice -DD
7107 if(sfx_voice[i] > 0)
7108 voice_set_volume(sfx_voice[i], sfx_volume);
7109 }
7110 zc_set_config(sfx_sect,"digi",digi_volume);
7111 zc_set_config(sfx_sect,"midi",midi_volume);
7112 zc_set_config(sfx_sect,"sfx",sfx_volume);
7113 zc_set_config(sfx_sect,"emusic",emusic_volume);
7114 zc_set_config(sfx_sect,"pan",pan_style);
7115 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7116 }
7117 else
7118 {
7119 midi_volume = m;
7120 digi_volume = d;
7121 emusic_volume = e;
7122 zcmusic_bufsz = b;
7123 sfx_volume = s;
7124 pan_style = p;
7125 }
7126
7127 return D_O_K;
7128 }
7129
7130 int32_t queding(char const* s1, char const* s2, char const* s3)
7131 {
7132 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7133 }
7134
7135 int32_t onQuit()
7136 {
7137 if(Playing)
7138 {
7139 int32_t ret=0;
7140
7141 if(get_bit(quest_rules, qr_NOCONTINUE))
7142 {
7143 if(standalone_mode)
7144 {
7145 ret=queding("End current game?",
7146 "The continue screen is disabled; the game",
7147 "will be reloaded from the last save.");
7148 }
7149 else
7150 {
7151 ret=queding("End current game?",
7152 "The continue screen is disabled. You will",
7153 "be returned to the file select screen.");
7154 }
7155 }
7156 else
7157 ret=queding("End current game?",NULL,NULL);
7158
7159 if(ret==1)
7160 {
7161 disableClickToFreeze=false;
7162 Quit=qQUIT;
7163
7164 // Trying to evade a door repair charge?
7165 if(repaircharge)
7166 {
7167 game->change_drupy(-repaircharge);
7168 repaircharge=0;
7169 }
7170
7171 return D_CLOSE;
7172 }
7173 }
7174
7175 return D_O_K;
7176 }
7177
7178 int32_t onTryQuitMenu()
7179 {
7180 return onTryQuit(true);
7181 }
7182
7183 int32_t onTryQuit(bool inMenu)
7184 {
7185 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7186 {
7187 if(active_cutscene.can_f6())
7188 {
7189 if(get_bit(quest_rules,qr_OLD_F6))
7190 {
7191 if(inMenu) onQuit();
7192 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7193 }
7194 else
7195 {
7196 disableClickToFreeze=false;
7197 GameFlags |= GAMEFLAG_TRYQUIT;
7198 }
7199 return D_CLOSE;
7200 }
7201 else active_cutscene.error();
7202 }
7203
7204 return D_O_K;
7205 }
7206
7207 int32_t onReset()
7208 {
7209 if(queding(" Reset system? ",NULL,NULL)==1)
7210 {
7211 disableClickToFreeze=false;
7212 Quit=qRESET;
7213 replay_quit();
7214 return D_CLOSE;
7215 }
7216
7217 return D_O_K;
7218 }
7219
7220 int32_t onExit()
7221 {
7222 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7223 {
7224 Quit=qEXIT;
7225 return D_CLOSE;
7226 }
7227
7228 return D_O_K;
7229 }
7230
7231 int32_t onTitle_NES()
7232 {
7233 title_version=0;
7234 zc_set_config(cfg_sect,"title",title_version);
7235 return D_O_K;
7236 }
7237 int32_t onTitle_DX()
7238 {
7239 title_version=1;
7240 zc_set_config(cfg_sect,"title",title_version);
7241 return D_O_K;
7242 }
7243 int32_t onTitle_25()
7244 {
7245 title_version=2;
7246 zc_set_config(cfg_sect,"title",title_version);
7247 return D_O_K;
7248 }
7249
7250 int32_t onDebug()
7251 {
7252 if(debug_enabled)
7253 set_debug(!get_debug());
7254 return D_O_K;
7255 }
7256
7257 int32_t onHeartBeep()
7258 {
7259 heart_beep=!heart_beep;
7260 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7261 return D_O_K;
7262 }
7263
7264 int32_t onSaveIndicator()
7265 {
7266 use_save_indicator=!use_save_indicator;
7267 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7268 return D_O_K;
7269 }
7270
7271 int32_t onEpilepsy()
7272 {
7273 if(jwin_alert3(
7274 "Epilepsy Flash Reduction",
7275 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7276 "Disabling this will restore standard flash and wavy behaviour.",
7277 "Proceed?",
7278 "&Yes",
7279 "&No",
7280 NULL,
7281 'y',
7282 'n',
7283 0,
7284 get_zc_font(font_lfont)) == 1)
7285 {
7286 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7287 zc_set_config("zeldadx","checked_epilepsy",1);
7288 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7289 }
7290 return D_O_K;
7291 }
7292
7293 int32_t onTriforce()
7294 {
7295 for(int32_t i=0; i<MAXINITTABS; ++i)
7296 {
7297 init_tabs[i].flags&=~D_SELECTED;
7298 }
7299
7300 init_tabs[3].flags=D_SELECTED;
7301 return onCheatConsole();
7302 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7303 for(int32_t i=1; i<=8; i++)
7304 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7305
7306 if(zc_popup_dialog (triforce_dlg,-1)==9)
7307 {
7308 for(int32_t i=1; i<=8; i++)
7309 {
7310 game->lvlitems[i] &= ~liTRIFORCE;
7311 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7312 }
7313 }
7314 return D_O_K;*/
7315 }
7316
7317 bool rc = false;
7318 /*
7319 int32_t onEquipment()
7320 {
7321 for (int32_t i=0; i<MAXINITTABS; ++i)
7322 {
7323 init_tabs[i].flags&=~D_SELECTED;
7324 }
7325 init_tabs[0].flags=D_SELECTED;
7326 return onCheatConsole();
7327 }
7328 */
7329
7330 int32_t onItems()
7331 {
7332 for(int32_t i=0; i<MAXINITTABS; ++i)
7333 {
7334 init_tabs[i].flags&=~D_SELECTED;
7335 }
7336
7337 init_tabs[1].flags=D_SELECTED;
7338 return onCheatConsole();
7339 }
7340
7341 static DIALOG getnum_dlg[] =
7342 {
7343 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7344 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7345 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7346 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7347 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7348 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7349 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7350 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7351 };
7352
7353 int32_t getnumber(const char *prompt,int32_t initialval)
7354 {
7355 char buf[20];
7356 sprintf(buf,"%d",initialval);
7357 getnum_dlg[0].dp=(void *)prompt;
7358 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7359 getnum_dlg[2].dp=buf;
7360
7361 large_dialog(getnum_dlg);
7362
7363 if(zc_popup_dialog(getnum_dlg,2)==3)
7364 return atoi(buf);
7365
7366 return initialval;
7367 }
7368
7369 int32_t onLife()
7370 {
7371 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7372 cheats_enqueue(Cheat::Life, value);
7373 return D_O_K;
7374 }
7375
7376 int32_t onHeartC()
7377 {
7378 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7379 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7380 cheats_enqueue(Cheat::MaxLife, max_life);
7381 cheats_enqueue(Cheat::Life, life);
7382 return D_O_K;
7383 }
7384
7385 int32_t onMagicC()
7386 {
7387 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7388 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7389 cheats_enqueue(Cheat::MaxMagic, max_magic);
7390 cheats_enqueue(Cheat::Magic, magic);
7391 return D_O_K;
7392 }
7393
7394 int32_t onRupies()
7395 {
7396 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7397 cheats_enqueue(Cheat::Rupies, value);
7398 return D_O_K;
7399 }
7400
7401 int32_t onMaxBombs()
7402 {
7403 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7404 cheats_enqueue(Cheat::MaxBombs, value);
7405 cheats_enqueue(Cheat::Bombs, value);
7406 return D_O_K;
7407 }
7408
7409 int32_t onRefillLife()
7410 {
7411 cheats_enqueue(Cheat::Life, game->get_maxlife());
7412 return D_O_K;
7413 }
7414 int32_t onRefillMagic()
7415 {
7416 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7417 return D_O_K;
7418 }
7419 int32_t onClock()
7420 {
7421 cheats_enqueue(Cheat::Clock);
7422 return D_O_K;
7423 }
7424
7425 int32_t onQstPath()
7426 {
7427 char path[2048];
7428
7429 chop_path(qstdir);
7430 strcpy(path,qstdir);
7431
7432 go();
7433
7434 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7435 {
7436 chop_path(path);
7437 fix_filename_case(path);
7438 fix_filename_slashes(path);
7439 strcpy(qstdir,path);
7440 strcpy(qstpath,qstdir);
7441 }
7442
7443 comeback();
7444 return D_O_K;
7445 }
7446
7447 #include "dialog/cheat_dialog.h"
7448 int32_t onCheat()
7449 {
7450 call_setcheat_dialog();
7451 game->set_cheat(maxcheat);
7452 if(cheat) game->did_cheat(true);
7453 return D_O_K;
7454 }
7455
7456 int32_t onCheatRupies()
7457 {
7458 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7459 return D_O_K;
7460 }
7461
7462 int32_t onCheatArrows()
7463 {
7464 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7465 return D_O_K;
7466 }
7467
7468 int32_t onCheatBombs()
7469 {
7470 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7471 return D_O_K;
7472 }
7473
7474 // *** screen saver
7475
7476 8132269 int32_t after_time()
7477 {
7478
1/2
✓ Branch 0 taken 8132269 times.
✗ Branch 1 not taken.
8132269 if(ss_enable == 0)
7479 return INT_MAX;
7480
7481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 0)
7482 return 5 * 60;
7483
7484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 3)
7485 return ss_after * 15 * 60;
7486
7487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132269 times.
8132269 if(ss_after <= 13)
7488 return (ss_after - 3) * 60 * 60;
7489
7490 8132269 return MAX_IDLE + 1;
7491 8132269 }
7492
7493 static const char *after_str[15] =
7494 {
7495 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7496 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7497 "Never"
7498 };
7499
7500 const char *after_list(int32_t index, int32_t *list_size)
7501 {
7502 if(index < 0)
7503 {
7504 *list_size = 15;
7505 return NULL;
7506 }
7507
7508 return after_str[index];
7509 }
7510
7511 33 static ListData after__list(after_list, &font);
7512
7513 static DIALOG scrsaver_dlg[] =
7514 {
7515 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7516 33 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7517 33 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7518 33 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7519 33 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7520 33 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7521 33 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7522 33 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7523 33 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7524 33 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7525 33 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7526 33 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7527 33 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7528 33 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7529 };
7530
7531 int32_t onScreenSaver()
7532 {
7533 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7534 int32_t oldcfgs[3];
7535 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7536 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7537 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7538
7539 large_dialog(scrsaver_dlg);
7540
7541 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7542
7543 if(ret == 8 || ret == 9)
7544 {
7545 ss_after = scrsaver_dlg[5].d1;
7546 ss_speed = scrsaver_dlg[6].d2;
7547 ss_density = scrsaver_dlg[7].d2;
7548 if(oldcfgs[0] != ss_after)
7549 zc_set_config(cfg_sect,"ss_after",ss_after);
7550 if(oldcfgs[1] != ss_speed)
7551 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7552 if(oldcfgs[2] != ss_density)
7553 zc_set_config(cfg_sect,"ss_density",ss_density);
7554 }
7555
7556 if(ret == 9)
7557 // preview Screen Saver
7558 {
7559 clear_keybuf();
7560 Matrix(ss_speed, ss_density, 30);
7561 system_pal();
7562 }
7563
7564 return D_O_K;
7565 }
7566
7567 /***** Menus *****/
7568
7569 static MENU game_menu[] =
7570 {
7571 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7572 { (char *)"", NULL, NULL, 0, NULL },
7573 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7574 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7575 { (char *)"", NULL, NULL, 0, NULL },
7576 #ifdef __EMSCRIPTEN__
7577 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7578 #elif defined(ALLEGRO_MACOSX)
7579 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7580 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7581 #else
7582 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7583 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7584 #endif
7585 { NULL, NULL, NULL, 0, NULL }
7586 };
7587
7588 static MENU title_menu[] =
7589 {
7590 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7591 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7592 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7593 { NULL, NULL, NULL, 0, NULL }
7594 };
7595
7596 static MENU snapshot_format_menu[] =
7597 {
7598 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7599 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7600 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7601 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7602 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7603 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7604 { NULL, NULL, NULL, 0, NULL }
7605 };
7606
7607 static MENU controls_menu[] =
7608 {
7609 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7610 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7611 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7612 { NULL, NULL, NULL, 0, NULL }
7613 };
7614
7615 static MENU name_entry_mode_menu[] =
7616 {
7617 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7618 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7619 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7620 { NULL, NULL, NULL, 0, NULL }
7621 };
7622
7623 static void set_controls_menu_active()
7624 {
7625
7626 }
7627
7628 static MENU window_menu[] =
7629 {
7630 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7631 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7632 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7633 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7634 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7635 { NULL, NULL, NULL, 0, NULL }
7636 };
7637 static MENU options_menu[] =
7638 {
7639 { "&Title Screen", NULL, title_menu, 0, NULL },
7640 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7641 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7642 { "&Window Settings", NULL, window_menu, 0, NULL },
7643 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7644 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7645 { NULL, NULL, NULL, 0, NULL }
7646 };
7647 static MENU settings_menu[] =
7648 {
7649 { "&Sound...", onSound, NULL, 0, NULL },
7650 { "C&ontrols", NULL, controls_menu, 0, NULL },
7651 { "", NULL, NULL, 0, NULL },
7652 { "Options", NULL, options_menu, 0, NULL },
7653 { "", NULL, NULL, 0, NULL },
7654 //
7655 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7656 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7657 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7658 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7659 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7660 //
7661 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7662 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7663 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7664 { "", NULL, NULL, 0, NULL },
7665 { "Debu&g", onDebug, NULL, 0, NULL },
7666 //
7667 { NULL, NULL, NULL, 0, NULL }
7668 };
7669
7670
7671 static MENU misc_menu[] =
7672 {
7673 { (char *)"&About...", onAbout, NULL, 0, NULL },
7674 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7675 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7676 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7677 { (char *)"", NULL, NULL, 0, NULL },
7678 //5
7679 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7680 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7681 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7682 { (char *)"", NULL, NULL, 0, NULL },
7683 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7684 //10
7685 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7686 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7687 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7688 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7689 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7690 //15
7691 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7692 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7693 { NULL, NULL, NULL, 0, NULL }
7694 };
7695
7696 static MENU refill_menu[] =
7697 {
7698 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7699 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7700 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7701 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7702 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7703 { NULL, NULL, NULL, 0, NULL }
7704 };
7705
7706 static MENU show_menu[] =
7707 {
7708 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7709 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7710 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7711 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7712 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7713 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7714 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7715 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7716 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7717 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7718 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7719 { (char *)"", NULL, NULL, 0, NULL },
7720 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7721 { (char *)"", NULL, NULL, 0, NULL },
7722 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7723 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7724 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7725 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7726 { NULL, NULL, NULL, 0, NULL }
7727 };
7728
7729 static MENU cheat_menu[] =
7730 {
7731 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7732 { (char *)"", NULL, NULL, 0, NULL },
7733 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7734 { (char *)"", NULL, NULL, 0, NULL },
7735 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7736 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7737 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7738 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7739 { (char *)"", NULL, NULL, 0, NULL },
7740 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7741 { (char *)"", NULL, NULL, 0, NULL },
7742 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7743 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7744 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7745 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7746 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7747 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7748 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7749 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7750 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7751 { NULL, NULL, NULL, 0, NULL }
7752 };
7753
7754 #if DEVLEVEL > 0
7755 int32_t devLogging();
7756 int32_t devDebug();
7757 int32_t devTimestmp();
7758 #if DEVLEVEL > 1
7759 int32_t setCheat();
7760 #endif //DEVLEVEL > 1
7761 enum
7762 {
7763 dv_log,
7764 // dv_dbg,
7765 dv_tmpstmp,
7766 #if DEVLEVEL > 1
7767 dv_nil,
7768 dv_setcheat,
7769 #endif //DEVLEVEL > 1
7770 dv_max
7771 };
7772 static MENU dev_menu[] =
7773 {
7774 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7775 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7776 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7777 #if DEVLEVEL > 1
7778 { (char *)"", NULL, NULL, 0, NULL },
7779 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7780 #endif //DEVLEVEL > 1
7781 { NULL, NULL, NULL, 0, NULL }
7782 };
7783 int32_t devLogging()
7784 {
7785 dev_logging = !dev_logging;
7786 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7787 return D_O_K;
7788 }
7789 // int32_t devDebug()
7790 // {
7791 // dev_debug = !dev_debug;
7792 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7793 // return D_O_K;
7794 // }
7795 int32_t devTimestmp()
7796 {
7797 dev_timestmp = !dev_timestmp;
7798 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7799 return D_O_K;
7800 }
7801 #if DEVLEVEL > 1
7802 int32_t setCheat()
7803 {
7804 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7805 return D_O_K;
7806 }
7807 #endif //DEVLEVEL > 1
7808 #endif //DEVLEVEL > 0
7809
7810 MENU the_player_menu[] =
7811 {
7812 { (char *)"&Game", NULL, game_menu, 0, NULL },
7813 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7814 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7815 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7816 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7817 #if DEVLEVEL > 0
7818 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7819 #endif
7820 { NULL, NULL, NULL, 0, NULL }
7821 };
7822 int32_t onMIDIPatch()
7823 {
7824 if(jwin_alert3(
7825 "Toggle Windows MIDI Fix",
7826 "This action will change whether ZC Player auto-restarts a MIDI at its",
7827 "last index if you move ZC Player out of focus, then back into focus.",
7828 "Proceed?",
7829 "&Yes",
7830 "&No",
7831 NULL,
7832 'y',
7833 'n',
7834 0,
7835 get_zc_font(font_lfont)) == 1)
7836 {
7837 midi_patch_fix = midi_patch_fix ? 0 : 1;
7838 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7839 }
7840 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7841 return D_O_K;
7842 }
7843
7844 int32_t onKeyboardEntry()
7845 {
7846 NameEntryMode=0;
7847 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7848 return D_O_K;
7849 }
7850
7851 int32_t onLetterGridEntry()
7852 {
7853 NameEntryMode=1;
7854 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7855 return D_O_K;
7856 }
7857
7858 int32_t onExtLetterGridEntry()
7859 {
7860 NameEntryMode=2;
7861 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7862 return D_O_K;
7863 }
7864
7865 static BITMAP* oldscreen;
7866 int32_t onFullscreenMenu()
7867 {
7868 // super hacks
7869 screen = oldscreen;
7870 if (onFullscreen() == D_REDRAW)
7871 {
7872 oldscreen = screen;
7873 }
7874 screen = menu_bmp;
7875 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7876 return D_O_K;
7877 }
7878
7879 33 void fix_menu()
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!debug_enabled)
7882 33 settings_menu[13].text = NULL;
7883 33 }
7884
7885 static DIALOG system_dlg[] =
7886 {
7887 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7888 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7889 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7890 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7891 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7892 #ifndef ALLEGRO_MACOSX
7893 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7894 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7895 #else
7896 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7897 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7898 #endif
7899 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7900 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7901 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7902 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7903 };
7904
7905 void reset_snapshot_format_menu()
7906 {
7907 for(int32_t i=0; i<ssfmtMAX; ++i)
7908 {
7909 snapshot_format_menu[i].flags=0;
7910 }
7911 }
7912
7913 int32_t onSetSnapshotFormat()
7914 {
7915 switch(active_menu->text[1])
7916 {
7917 case 'B': //"&BMP"
7918 SnapshotFormat=0;
7919 break;
7920
7921 case 'G': //"&GIF"
7922 SnapshotFormat=1;
7923 break;
7924
7925 case 'J': //"&JPG"
7926 SnapshotFormat=2;
7927 break;
7928
7929 case 'P': //"&PNG"
7930 SnapshotFormat=3;
7931 break;
7932
7933 case 'C': //"PC&X"
7934 SnapshotFormat=4;
7935 break;
7936
7937 case 'T': //"&TGA"
7938 SnapshotFormat=5;
7939 break;
7940
7941 case 'L': //"&LBM"
7942 SnapshotFormat=6;
7943 break;
7944 }
7945 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7946
7947 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7948 return D_O_K;
7949 }
7950
7951
7952 47 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7953 {
7954 PALETTE tmp;
7955
7956
2/2
✓ Branch 0 taken 12032 times.
✓ Branch 1 taken 47 times.
12079 for(int32_t i=0; i<256; i++)
7957 {
7958 12032 tmp[i].r=r;
7959 12032 tmp[i].g=g;
7960 12032 tmp[i].b=b;
7961 12032 }
7962
7963 47 fade_interpolate(src,tmp,dest,pos,from,to);
7964 47 }
7965
7966 47 void system_pal()
7967 {
7968 47 is_sys_pal = true;
7969 static PALETTE pal;
7970 47 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7971
7972 // set up the grayscale palette
7973
2/2
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 47 times.
3055 for(int32_t i=128; i<192; i++)
7974 {
7975 3008 pal[i].r = i-128;
7976 3008 pal[i].g = i-128;
7977 3008 pal[i].b = i-128;
7978 3008 }
7979 47 load_colorset(gui_colorset, pal, jwin_a5_colors);
7980
7981 47 color_layer(pal, pal, 24,16,16, 28, 128,191);
7982
7983
2/2
✓ Branch 0 taken 6016 times.
✓ Branch 1 taken 47 times.
6063 for(int32_t i=0; i<256; i+=2)
7984 {
7985 6016 int32_t v = (i>>3)+2;
7986 6016 int32_t c = (i>>3)+192;
7987 6016 pal[c] = _RGB(v,v,v+(v>>1));
7988 /*
7989 if(i<240)
7990 {
7991 _allegro_hline(tmp_scr,0,i,319,c);
7992 _allegro_hline(tmp_scr,0,i+1,319,c);
7993 }
7994 */
7995 6016 }
7996
7997 // draw the vertical screen gradient
7998
2/2
✓ Branch 0 taken 11280 times.
✓ Branch 1 taken 47 times.
11327 for(int32_t i=0; i<240; ++i)
7999 {
8000 11280 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8001 11280 }
8002
8003 /*
8004 palrstart= 10*63/255; palrend=166*63/255;
8005 palgstart= 36*63/255; palgend=202*63/255;
8006 palbstart=106*63/255; palbend=240*63/255;
8007 paldivs=32;
8008 for(int32_t i=0; i<paldivs; i++)
8009 {
8010 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8011 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8012 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8013 }
8014 */
8015 47 BITMAP *panorama = create_bitmap_ex(8,256,224);
8016 int32_t ts_height, ts_start;
8017
8018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8019 {
8020 clear_to_color(panorama,0);
8021 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8022 ts_height=224-passive_subscreen_height;
8023 ts_start=28;
8024 }
8025 else
8026 {
8027 47 blit(framebuf,panorama,0,0,0,0,256,224);
8028 47 ts_height=224;
8029 47 ts_start=0;
8030 }
8031
8032 // gray scale the current frame
8033
2/2
✓ Branch 0 taken 10528 times.
✓ Branch 1 taken 47 times.
10575 for(int32_t y=0; y<ts_height; y++)
8034 {
8035
2/2
✓ Branch 0 taken 2695168 times.
✓ Branch 1 taken 10528 times.
2705696 for(int32_t x=0; x<256; x++)
8036 {
8037 2695168 int32_t c = panorama->line[y+ts_start][x];
8038
2/2
✓ Branch 0 taken 2689245 times.
✓ Branch 1 taken 5923 times.
2695168 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8039 2695168 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8040 2695168 }
8041 10528 }
8042
8043 47 destroy_bitmap(panorama);
8044
8045 // display everything
8046 47 vsync();
8047 47 hw_palette = &pal;
8048 47 update_hw_pal = true;
8049
8050 // sys_pal = pal;
8051 47 memcpy(sys_pal,pal,sizeof(pal));
8052 47 }
8053
8054 void system_pal2()
8055 {
8056 is_sys_pal = true;
8057 static PALETTE RAMpal2;
8058 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8059
8060 /* Windows 2000 colors
8061 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8062 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8063 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8064 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8065 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8066 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8067 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8068 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8069
8070 byte palrstart= 10*63/255, palrend=166*63/255,
8071 palgstart= 36*63/255, palgend=202*63/255,
8072 palbstart=106*63/255, palbend=240*63/255,
8073 paldivs=7;
8074 for(int32_t i=0; i<paldivs; i++)
8075 {
8076 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8077 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8078 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8079 }
8080 */
8081
8082 /* Windows 98 colors
8083 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8084 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8085 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8086 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8087 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8088 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8089 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8090 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8091
8092 byte palrstart= 0*63/255, palrend=166*63/255,
8093 palgstart= 0*63/255, palgend=202*63/255,
8094 palbstart=128*63/255, palbend=240*63/255,
8095 paldivs=7;
8096 for(int32_t i=0; i<paldivs; i++)
8097 {
8098 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8099 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8100 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8101 }
8102 */
8103
8104 /* Windows 99 colors
8105 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8106 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8107 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8108 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8109 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8110 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8111 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8112 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8113 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8114
8115 byte palrstart= 0*63/255, palrend=166*63/255,
8116 palgstart= 0*63/255, palgend=202*63/255,
8117
8118 palbstart=128*63/255, palbend=240*63/255,
8119 paldivs=6;
8120 for(int32_t i=0; i<paldivs; i++)
8121 {
8122 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8123 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8124 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8125 }
8126 */
8127
8128
8129
8130 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8131 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8132 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8133 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8134 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8135 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8136 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8137 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8138 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8139
8140 byte palrstart= 0*63/255, palrend=166*63/255,
8141 palgstart= 0*63/255, palgend=202*63/255,
8142 palbstart=128*63/255, palbend=240*63/255,
8143 paldivs=6;
8144
8145 for(int32_t i=0; i<paldivs; i++)
8146 {
8147 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8148 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8149 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8150 }
8151
8152 gui_bg_color=jwin_pal[jcBOX];
8153 gui_fg_color=jwin_pal[jcBOXFG];
8154
8155 jwin_set_colors(jwin_pal);
8156
8157
8158 // set up the new palette
8159 for(int32_t i=128; i<192; i++)
8160 {
8161 RAMpal2[i].r = i-128;
8162 RAMpal2[i].g = i-128;
8163 RAMpal2[i].b = i-128;
8164 }
8165
8166 /*
8167 for(int32_t i=0; i<64; i++)
8168 {
8169 RAMpal2[128+i] = _RGB(i,i,i)1));
8170 }
8171 */
8172
8173 /*
8174
8175 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8176 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8177 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8178 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8179 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8180 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8181 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8182
8183 gui_fg_color=vc(14);
8184 gui_bg_color=vc(1);
8185
8186 jwin_set_colors(jwin_pal);
8187 */
8188
8189 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8190
8191 // set up the colors for the vertical screen gradient
8192 for(int32_t i=0; i<256; i+=2)
8193 {
8194 int32_t v = (i>>3)+2;
8195 int32_t c = (i>>3)+192;
8196 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8197
8198 /*
8199 if(i<240)
8200 {
8201 _allegro_hline(tmp_scr,0,i,319,c);
8202 _allegro_hline(tmp_scr,0,i+1,319,c);
8203 }
8204 */
8205 }
8206
8207 // hw_palette = &RAMpal;
8208 // update_hw_pal = true;
8209
8210 for(int32_t i=0; i<240; ++i)
8211 {
8212 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8213 }
8214
8215 /*
8216 byte palrstart= 10*63/255, palrend=166*63/255,
8217 palgstart= 36*63/255, palgend=202*63/255,
8218 palbstart=106*63/255, palbend=240*63/255,
8219 paldivs=32;
8220 for(int32_t i=0; i<paldivs; i++)
8221 {
8222 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8223 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8224 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8225 }
8226 */
8227 BITMAP *panorama = create_bitmap_ex(8,256,224);
8228 int32_t ts_height, ts_start;
8229
8230 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8231 {
8232 clear_to_color(panorama,0);
8233 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8234 ts_height=224-passive_subscreen_height;
8235 ts_start=28;
8236 }
8237 else
8238 {
8239 blit(framebuf,panorama,0,0,0,0,256,224);
8240 ts_height=224;
8241 ts_start=0;
8242 }
8243
8244 // gray scale the current frame
8245 for(int32_t y=0; y<ts_height; y++)
8246 {
8247 for(int32_t x=0; x<256; x++)
8248 {
8249 int32_t c = panorama->line[y+ts_start][x];
8250 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8251 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8252 }
8253 }
8254
8255 destroy_bitmap(panorama);
8256
8257 // display everything
8258 vsync();
8259 hw_palette = &RAMpal2;
8260 update_hw_pal = true;
8261
8262 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8263
8264 // sys_pal = pal;
8265 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8266 }
8267
8268 static uint32_t entered_sys_pal = 0;
8269 14 void enter_sys_pal()
8270 {
8271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8272 {
8273 if(entered_sys_pal)
8274 ++entered_sys_pal;
8275 return;
8276 }
8277 14 sys_mouse();
8278 14 system_pal();
8279 14 ++entered_sys_pal;
8280 14 }
8281 14 void exit_sys_pal()
8282 {
8283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8284 {
8285
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8286 {
8287 14 game_pal();
8288 14 game_mouse();
8289 14 }
8290 14 }
8291 14 }
8292
8293 void switch_out_callback()
8294 {
8295 if (pause_in_background)
8296 {
8297 callback_switchin = 3;
8298 return;
8299 }
8300
8301 #ifdef _WIN32
8302 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8303 return;
8304
8305
8306 paused_midi_pos = midi_pos;
8307 zc_stop_midi();
8308 midi_paused=true;
8309 midi_suspended = midissuspHALTED;
8310 #endif
8311 }
8312
8313 void switch_in_callback()
8314 {
8315 if(pause_in_background)
8316 {
8317 return;
8318 }
8319
8320 #ifdef _WIN32
8321 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8322 return;
8323
8324 else
8325 {
8326 callback_switchin = 1;
8327 midi_suspended = midissuspRESUME;
8328 }
8329 #endif
8330 }
8331
8332 342 void game_pal()
8333 {
8334 342 is_sys_pal = false;
8335 342 entered_sys_pal = 0;
8336 342 clear_to_color(screen,BLACK);
8337 342 hw_palette = &RAMpal;
8338 342 update_hw_pal = true;
8339 342 }
8340
8341 static char bar_str[] = "";
8342
8343 14 void music_pause()
8344 {
8345 //al_pause_duh(tmplayer);
8346 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8347 14 zc_midi_pause();
8348 14 midi_paused=true;
8349 14 }
8350
8351 void music_resume()
8352 {
8353 //al_resume_duh(tmplayer);
8354 zcmusic_pause(zcmusic, ZCM_RESUME);
8355 zc_midi_resume();
8356 midi_paused=false;
8357 }
8358
8359 6588 void music_stop()
8360 {
8361 //al_stop_duh(tmplayer);
8362 //unload_duh(tmusic);
8363 //tmusic=NULL;
8364 //tmplayer=NULL;
8365 6588 zcmusic_stop(zcmusic);
8366 6588 zcmusic_unload_file(zcmusic);
8367 6588 zc_stop_midi();
8368 6588 midi_paused=false;
8369 6588 currmidi=-1;
8370 6588 }
8371
8372 void System()
8373 {
8374 mouse_down=gui_mouse_b();
8375 music_pause();
8376 pause_all_sfx();
8377 MenuOpen = true;
8378 system_pal();
8379 // FONT *oldfont=font;
8380 // font=tfont;
8381
8382 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8383 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8384
8385 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8386 #if DEVLEVEL > 1
8387 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8388 #endif
8389 game_menu[3].flags =
8390 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8391 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8392 clear_keybuf();
8393 sys_mouse();
8394
8395 DIALOG_PLAYER *p;
8396
8397 clear_bitmap(menu_bmp);
8398 oldscreen = screen;
8399 screen = menu_bmp;
8400
8401 p = init_dialog(system_dlg,-1);
8402
8403 // drop the menu on startup if menu button pressed
8404 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8405 simulate_keypress(KEY_G << 8);
8406
8407 do
8408 {
8409 if(close_button_quit)
8410 {
8411 close_button_quit = false;
8412 f_Quit(qEXIT);
8413 if(Quit) break;
8414 }
8415 rest(17);
8416
8417 if(mouse_down && !gui_mouse_b())
8418 mouse_down=0;
8419
8420 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8421 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8422 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8423
8424 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8425 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8426 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8427 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8428 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8429 settings_menu[10].flags = NESquit?D_SELECTED:0;
8430 settings_menu[11].flags = volkeys?D_SELECTED:0;
8431
8432 window_menu[0].flags = DragAspect?D_SELECTED:0;
8433 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8434 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8435 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8436 window_menu[4].flags = stretchGame?D_SELECTED:0;
8437
8438 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8439 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8440
8441 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8442 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8443 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8444
8445 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8446 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8447 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8448 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8449
8450 bool nocheat = (replay_is_replaying() || !Playing
8451 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8452 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8453 cheat_menu[0].flags = 0;
8454 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8455 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8456 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8457 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8458 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8459 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8460 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8461 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8462 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8463
8464 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8465 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8466 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8467 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8468 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8469 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8470 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8471 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8472 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8473 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8474 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8475 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8476 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8477 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8478 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8479
8480 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8481 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8482
8483 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8484 (char *)"Disable recording new saves" :
8485 (char *)"Enable recording new saves";
8486 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8487 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8488 (char *)"Stop recording" :
8489 (char *)"Stop replaying";
8490 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8491 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8492 (char *)"Disable snapshot all frames" :
8493 (char *)"Enable snapshot all frames";
8494
8495 reset_snapshot_format_menu();
8496 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8497
8498 if(debug_enabled)
8499 {
8500 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8501 }
8502
8503 if(gui_mouse_b() && !mouse_down)
8504 break;
8505
8506 // press menu to drop the menu
8507 if(rMbtn())
8508 simulate_keypress(KEY_G << 8);
8509
8510 if(input_idle(true) > after_time())
8511 // run Screeen Saver
8512 {
8513 // Screen saver enabled for now.
8514 clear_keybuf();
8515 Matrix(ss_speed, ss_density, 0);
8516 system_pal();
8517 broadcast_dialog_message(MSG_DRAW, 0);
8518 }
8519
8520 update_hw_screen();
8521 }
8522 while(update_dialog(p));
8523
8524 screen = oldscreen;
8525
8526 // font=oldfont;
8527 mouse_down=gui_mouse_b();
8528 shutdown_dialog(p);
8529 game_mouse();
8530 MenuOpen = false;
8531 if(Quit)
8532 {
8533 kill_sfx();
8534 music_stop();
8535 update_hw_screen();
8536 }
8537 else
8538 {
8539 game_pal();
8540 music_resume();
8541 resume_all_sfx();
8542
8543 if(rc)
8544 ringcolor(false);
8545 }
8546
8547 eat_buttons();
8548
8549 rc=false;
8550 clear_keybuf();
8551 // text_mode(0);
8552 }
8553
8554 33 void fix_dialogs()
8555 {
8556 33 jwin_center_dialog(about_dlg);
8557 33 jwin_center_dialog(gamepad_dlg);
8558 33 jwin_center_dialog(credits_dlg);
8559 33 jwin_center_dialog(gamemode_dlg);
8560 33 jwin_center_dialog(getnum_dlg);
8561 33 jwin_center_dialog(goto_dlg);
8562 33 jwin_center_dialog(keyboard_control_dlg);
8563 33 jwin_center_dialog(midi_dlg);
8564 33 jwin_center_dialog(quest_dlg);
8565 33 jwin_center_dialog(scrsaver_dlg);
8566 33 jwin_center_dialog(sound_dlg);
8567 33 jwin_center_dialog(triforce_dlg);
8568
8569 // digi_dp[1] += scrx;
8570 // digi_dp[2] += scry;
8571 // midi_dp[1] += scrx;
8572 // midi_dp[2] += scry;
8573 // pan_dp[1] += scrx;
8574 // pan_dp[2] += scry;
8575 // emus_dp[1] += scrx;
8576 // emus_dp[2] += scry;
8577 // buf_dp[1] += scrx;
8578 // buf_dp[2] += scry;
8579 // sfx_dp[1] += scrx;
8580 // sfx_dp[2] += scry;
8581 33 }
8582
8583 /*****************************/
8584 /**** Custom Sound System ****/
8585 /*****************************/
8586
8587 2893 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8588 {
8589
3/4
✓ Branch 0 taken 2635 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2893 times.
✗ Branch 3 not taken.
2893 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8590 }
8591
8592 // Run an NSF, or a MIDI if the NSF is missing somehow.
8593 105 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8594 {
8595 105 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8596
8597 // Found it
8598
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 38 times.
105 if(newzcmusic!=NULL)
8599 {
8600 67 zcmusic_stop(zcmusic);
8601 67 zcmusic_unload_file(zcmusic);
8602 67 zc_stop_midi();
8603
8604 67 zcmusic=newzcmusic;
8605 67 zcmusic_play(zcmusic, emusic_volume);
8606
8607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(track>0)
8608 67 zcmusic_change_track(zcmusic,track);
8609
8610 67 return true;
8611 }
8612
8613 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8614
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8615 jukebox(midi);
8616
8617 38 return false;
8618 105 }
8619
8620 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8621 {
8622 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8623 // Found it
8624 if(newzcmusic!=NULL)
8625 {
8626 zcmusic_stop(zcmusic);
8627 zcmusic_unload_file(zcmusic);
8628 zc_stop_midi();
8629
8630 zcmusic=newzcmusic;
8631 zcmusic_play(zcmusic, emusic_volume);
8632
8633 if(track>0)
8634 zcmusic_change_track(zcmusic,track);
8635
8636 return true;
8637 }
8638
8639 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8640 else if(midi>-1000)
8641 jukebox(midi);
8642
8643 return false;
8644 }
8645
8646 int32_t get_zcmusicpos()
8647 {
8648 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8649 return debugtracething;
8650 return 0;
8651 }
8652
8653 void set_zcmusicpos(int32_t position)
8654 {
8655 zcmusic_set_curpos(zcmusic, position);
8656 }
8657
8658 void set_zcmusicspeed(int32_t speed)
8659 {
8660 int32_t newspeed = vbound(speed, 0, 10000);
8661 zcmusic_set_speed(zcmusic, newspeed);
8662 }
8663
8664 1430 void jukebox(int32_t index,int32_t loop)
8665 {
8666 1430 music_stop();
8667
8668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8669
8670
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8671
8672 1430 music_stop();
8673
8674 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8675 // stuck notes when a song stops. This fixes it.
8676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8677 zc_set_volume(0, 0);
8678
8679 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8680 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8681
8682
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8683 402 zc_midi_seek(tunes[index].start);
8684
8685 1430 midi_loop_start = tunes[index].loop_start;
8686 1430 midi_loop_end = tunes[index].loop_end;
8687
8688 1430 currmidi=index;
8689 1430 master_volume(digi_volume,midi_volume);
8690 1430 midi_paused=false;
8691 1430 }
8692
8693 11423 void jukebox(int32_t index)
8694 {
8695
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index<0) index=MAXMIDIS-1;
8696
8697
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index>=MAXMIDIS) index=0;
8698
8699 // do nothing if it's already playing
8700
3/4
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9993 times.
✗ Branch 3 not taken.
11423 if(index==currmidi && midi_pos>=0)
8701 {
8702 9993 midi_paused=false;
8703 9993 return;
8704 }
8705
8706 1430 jukebox(index,tunes[index].loop);
8707 11423 }
8708
8709 12753 void play_DmapMusic()
8710 {
8711 static char tfile[2048];
8712 static int32_t ttrack=0;
8713 12753 bool domidi=false;
8714
8715
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 11299 times.
12753 if(DMaps[currdmap].tmusic[0]!=0)
8716 {
8717
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1069 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1839 if(zcmusic==NULL ||
8718
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8719
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8720 {
8721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1069 times.
1069 if(zcmusic != NULL)
8722 {
8723 zcmusic_stop(zcmusic);
8724 zcmusic_unload_file(zcmusic);
8725 zcmusic = NULL;
8726 }
8727
8728 1069 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8729
8730
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 983 times.
1069 if(zcmusic!=NULL)
8731 {
8732 86 zc_stop_midi();
8733 86 strcpy(tfile,DMaps[currdmap].tmusic);
8734 86 zcmusic_play(zcmusic, emusic_volume);
8735 86 int32_t temptracks=0;
8736 86 temptracks=zcmusic_get_tracks(zcmusic);
8737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8738 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8739 86 zcmusic_change_track(zcmusic,ttrack);
8740 86 }
8741 else
8742 {
8743 983 tfile[0] = 0;
8744 983 domidi=true;
8745 }
8746 1069 }
8747 1454 }
8748 else
8749 {
8750 11299 domidi=true;
8751 }
8752
8753
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 12282 times.
12753 if(domidi)
8754 {
8755 12282 int32_t m=DMaps[currdmap].midi;
8756
8757
3/4
✓ Branch 0 taken 11875 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
12282 switch(m)
8758 {
8759 case 1:
8760 368 jukebox(ZC_MIDI_OVERWORLD);
8761 368 break;
8762
8763 case 2:
8764 39 jukebox(ZC_MIDI_DUNGEON);
8765 39 break;
8766
8767 case 3:
8768 jukebox(ZC_MIDI_LEVEL9);
8769 break;
8770
8771 default:
8772
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11875 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8773 10843 jukebox(m+MIDIOFFSET_DMAP);
8774 else
8775 1032 music_stop();
8776 11875 }
8777 12282 }
8778 12753 }
8779
8780 12791 void playLevelMusic()
8781 {
8782 12791 int32_t m=tmpscr->screen_midi;
8783
8784
3/6
✓ Branch 0 taken 12737 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12791 switch(m)
8785 {
8786 case -2:
8787 13 music_stop();
8788 13 break;
8789
8790 case -1:
8791 12737 play_DmapMusic();
8792 12737 break;
8793
8794 case 1:
8795 jukebox(ZC_MIDI_OVERWORLD);
8796 break;
8797
8798 case 2:
8799 jukebox(ZC_MIDI_DUNGEON);
8800 break;
8801
8802 case 3:
8803 jukebox(ZC_MIDI_LEVEL9);
8804 break;
8805
8806 default:
8807
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8808 41 jukebox(m+MIDIOFFSET_MAPSCR);
8809 else
8810 music_stop();
8811 41 }
8812 12791 }
8813
8814 1463 void master_volume(int32_t dv,int32_t mv)
8815 {
8816
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1463 times.
✗ Branch 7 not taken.
1463 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8817
8818
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1463 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1463 times.
✗ Branch 7 not taken.
1463 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8819
8820
6/6
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 1461 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1423 times.
✓ Branch 5 taken 38 times.
1463 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8821 1463 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8822 1463 }
8823
8824 /*****************/
8825 /***** SFX *****/
8826 /*****************/
8827
8828 // array of voices, one for each sfx sample in the data file
8829 // 0+ = voice #
8830 // -1 = voice not allocated
8831 33 void Z_init_sound()
8832 {
8833
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 33 times.
8481 for(int32_t i=0; i<WAV_COUNT; i++)
8834 8448 sfx_voice[i]=-1;
8835
8836
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 33 times.
264 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8837 231 tunes[i].data = (MIDI*)mididata[i].dat;
8838
8839
2/2
✓ Branch 0 taken 8316 times.
✓ Branch 1 taken 33 times.
8349 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8840 8316 tunes[ZC_MIDI_COUNT+j].data=NULL;
8841
8842 33 master_volume(digi_volume,midi_volume);
8843 33 }
8844
8845 // returns number of voices currently allocated
8846 int32_t sfx_count()
8847 {
8848 int32_t c=0;
8849
8850 for(int32_t i=0; i<WAV_COUNT; i++)
8851 if(sfx_voice[i]!=-1)
8852 ++c;
8853
8854 return c;
8855 }
8856
8857 // clean up finished samples
8858 8085587 void sfx_cleanup()
8859 {
8860
2/2
✓ Branch 0 taken 2069910272 times.
✓ Branch 1 taken 8085587 times.
2077995859 for(int32_t i=0; i<WAV_COUNT; i++)
8861
3/4
✓ Branch 0 taken 634378 times.
✓ Branch 1 taken 2069275894 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 634378 times.
2070544650 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8862 {
8863 634378 deallocate_voice(sfx_voice[i]);
8864 634378 sfx_voice[i]=-1;
8865 634378 }
8866 8085587 }
8867
8868 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8869 // if a voice is already allocated (and/or playing), then it just returns true
8870 // Returns true: voice is allocated
8871 // false: unsuccessful
8872 974584 bool sfx_init(int32_t index)
8873 {
8874 // check index
8875
3/4
✓ Branch 0 taken 703299 times.
✓ Branch 1 taken 271285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703299 times.
974584 if(index<=0 || index>=WAV_COUNT)
8876 271285 return false;
8877
8878
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 634405 times.
703299 if(sfx_voice[index]==-1)
8879 {
8880
2/2
✓ Branch 0 taken 182178 times.
✓ Branch 1 taken 452227 times.
634405 if(sfxdat)
8881 {
8882
1/2
✓ Branch 0 taken 182178 times.
✗ Branch 1 not taken.
182178 if(index<Z35)
8883 {
8884 182178 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8885 182178 }
8886 else
8887 {
8888 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8889 }
8890 182178 }
8891 else
8892 {
8893 452227 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8894 }
8895
8896 634405 voice_set_volume(sfx_voice[index], sfx_volume);
8897 634405 }
8898
8899 703299 return sfx_voice[index] != -1;
8900 974584 }
8901
8902 // plays an sfx sample
8903 829405 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8904 {
8905
2/2
✓ Branch 0 taken 630894 times.
✓ Branch 1 taken 198511 times.
829405 if(!sfx_init(index))
8906 198511 return;
8907
8908 630894 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8909 630894 voice_set_pan(sfx_voice[index],pan);
8910
8911 630894 int32_t pos = voice_get_position(sfx_voice[index]);
8912
8913
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332848 times.
630894 if(restart) voice_set_position(sfx_voice[index],0);
8914
8915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630894 times.
630894 if(pos<=0)
8916 630894 voice_start(sfx_voice[index]);
8917
8918
3/4
✓ Branch 0 taken 332848 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332848 times.
630894 if (restart && replay_is_debug())
8919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332848 times.
332848 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8920 829405 }
8921
8922 // true if sfx is allocated
8923 35405 bool sfx_allocated(int32_t index)
8924 {
8925
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 25998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35405 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8926 }
8927
8928 // start it (in loop mode) if it's not already playing,
8929 // otherwise adjust it to play in loop mode -DD
8930 145179 void cont_sfx(int32_t index)
8931 {
8932
2/2
✓ Branch 0 taken 72774 times.
✓ Branch 1 taken 72405 times.
145179 if(!sfx_init(index))
8933 {
8934 72774 return;
8935 }
8936
8937
1/2
✓ Branch 0 taken 72405 times.
✗ Branch 1 not taken.
72405 if(voice_get_position(sfx_voice[index])<=0)
8938 {
8939 72405 voice_set_position(sfx_voice[index],0);
8940 72405 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8941 72405 voice_start(sfx_voice[index]);
8942 72405 }
8943 else
8944 {
8945 adjust_sfx(index, 128, true);
8946 }
8947 145179 }
8948
8949 // adjust parameters while playing
8950 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8951 {
8952
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8953 3947 return;
8954
8955 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8956 14 voice_set_pan(sfx_voice[index],pan);
8957 3961 }
8958
8959 // pauses a voice
8960 1651 void pause_sfx(int32_t index)
8961 {
8962
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8963 voice_stop(sfx_voice[index]);
8964 1651 }
8965
8966 // resumes a voice
8967 709 void resume_sfx(int32_t index)
8968 {
8969
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8970 voice_start(sfx_voice[index]);
8971 709 }
8972
8973 // pauses all active voices
8974 320 void pause_all_sfx()
8975 {
8976
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 320 times.
82240 for(int32_t i=0; i<WAV_COUNT; i++)
8977
2/2
✓ Branch 0 taken 81919 times.
✓ Branch 1 taken 1 times.
81921 if(sfx_voice[i]!=-1)
8978 1 voice_stop(sfx_voice[i]);
8979 320 }
8980
8981 // resumes all paused voices
8982 306 void resume_all_sfx()
8983 {
8984
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8985
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8986 voice_start(sfx_voice[i]);
8987 306 }
8988
8989 // stops an sfx and deallocates the voice
8990 6474364 void stop_sfx(int32_t index)
8991 {
8992
3/4
✓ Branch 0 taken 5333163 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5333163 times.
✗ Branch 3 not taken.
6474364 if(index<=0 || index>=WAV_COUNT)
8993 1141201 return;
8994
8995
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5333150 times.
5333163 if(sfx_voice[index]!=-1)
8996 {
8997 13 deallocate_voice(sfx_voice[index]);
8998 13 sfx_voice[index]=-1;
8999 13 }
9000 6474364 }
9001
9002 // Stops SFX played by Hero's item of the given family
9003 134717 void stop_item_sfx(int32_t family)
9004 {
9005 134717 int32_t id=current_item_id(family);
9006
9007
2/2
✓ Branch 0 taken 134251 times.
✓ Branch 1 taken 466 times.
134717 if(id<0)
9008 134251 return;
9009
9010 466 stop_sfx(itemsbuf[id].usesound);
9011 134717 }
9012
9013 2357 void kill_sfx()
9014 {
9015
2/2
✓ Branch 0 taken 603392 times.
✓ Branch 1 taken 2357 times.
605749 for(int32_t i=0; i<WAV_COUNT; i++)
9016
2/2
✓ Branch 0 taken 603378 times.
✓ Branch 1 taken 14 times.
603406 if(sfx_voice[i]!=-1)
9017 {
9018 14 deallocate_voice(sfx_voice[i]);
9019 14 sfx_voice[i]=-1;
9020 14 }
9021 2357 }
9022
9023 583542 int32_t pan(int32_t x)
9024 {
9025
1/4
✓ Branch 0 taken 583542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583542 switch(pan_style)
9026 {
9027 case 0:
9028 return 128;
9029
9030 case 1:
9031 583542 return vbound((x>>1)+68,0,255);
9032
9033 case 2:
9034 return vbound(((x*3)>>2)+36,0,255);
9035 }
9036
9037 return vbound(x,0,255);
9038 583542 }
9039
9040 /*******************************/
9041 /******* Input Handlers ********/
9042 /*******************************/
9043
9044 21804575 bool joybtn(int32_t b)
9045 {
9046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21804575 times.
21804575 if(b == 0)
9047 return false;
9048
9049 21804575 return joy[joystick_index].button[b-1].b !=0;
9050 21804575 }
9051
9052 const char* joybtn_name(int32_t b)
9053 {
9054 if(b == 0)
9055 return "";
9056
9057 return joy[joystick_index].button[b-1].name;
9058 }
9059
9060 int32_t next_press_key();
9061
9062 int32_t next_press_btn()
9063 {
9064 clear_keybuf();
9065 /*bool b[joy[joystick_index].num_buttons+1];
9066
9067 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9068 b[i]=joybtn(i);*/
9069
9070 //first, we need to wait until they're pressing no buttons
9071 for(;;)
9072 {
9073 if(keypressed())
9074 {
9075 switch(readkey()>>8)
9076 {
9077 case KEY_ESC:
9078 return -1;
9079
9080 case KEY_SPACE:
9081 return 0;
9082 }
9083 }
9084
9085 poll_joystick();
9086 bool done = true;
9087
9088 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9089 {
9090 if(joybtn(i)) done = false;
9091 }
9092
9093 if(done) break;
9094 rest(1);
9095 }
9096
9097 //now, we need to wait for them to press any button
9098 for(;;)
9099 {
9100 if(keypressed())
9101 {
9102 switch(readkey()>>8)
9103 {
9104 case KEY_ESC:
9105 return -1;
9106
9107 case KEY_SPACE:
9108 return 0;
9109 }
9110 }
9111
9112 poll_joystick();
9113
9114 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9115 {
9116 if(joybtn(i)) return i;
9117 }
9118 rest(1);
9119 }
9120 }
9121
9122 168538685 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9123 {
9124
2/2
✓ Branch 0 taken 162647457 times.
✓ Branch 1 taken 5891228 times.
168538685 bool ret = btn && !flag;
9125
2/2
✓ Branch 0 taken 142419089 times.
✓ Branch 1 taken 26119596 times.
168538685 flag = rawbtn ? *rawbtn : btn;
9126
9127 168538685 return ret;
9128 }
9129 1646643 static bool rButtonPeek(bool btn, bool flag)
9130 {
9131
2/2
✓ Branch 0 taken 1533938 times.
✓ Branch 1 taken 112705 times.
1646643 if(!btn)
9132 {
9133 1533938 return false;
9134 }
9135
2/2
✓ Branch 0 taken 16409 times.
✓ Branch 1 taken 96296 times.
112705 else if(!flag)
9136 {
9137 16409 return true;
9138 }
9139
9140 96296 return false;
9141 1646643 }
9142
9143 // Updated only by keyboard/gamepad.
9144 // If in replay mode, this is set directly by the replay system.
9145 // This should never be read from directly - use control_state instead.
9146 bool raw_control_state[ZC_CONTROL_STATES];
9147
9148 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9149 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9150 // lasts until the next call to load_control_state.
9151 bool control_state[ZC_CONTROL_STATES];
9152 bool disable_control[ZC_CONTROL_STATES];
9153 bool drunk_toggle_state[11];
9154 bool disabledKeys[127];
9155 bool KeyInput[127];
9156 bool KeyPress[127];
9157
9158 bool key_current_frame[127];
9159 bool key_previous_frame[127];
9160
9161 static bool key_system[127];
9162 static bool key_system_previous[127];
9163 static bool key_system_press[127];
9164
9165 bool button_press[ZC_CONTROL_STATES];
9166 bool button_hold[ZC_CONTROL_STATES];
9167
9168 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9169 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9170 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9171 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9172 #define STICK_PRECISION 56 //define your own sensitivity
9173
9174 6818528 void load_control_state()
9175 {
9176 6818528 load_control_called_this_frame = true;
9177
9178
4/4
✓ Branch 0 taken 3947327 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1294575 times.
✓ Branch 3 taken 2652752 times.
6818528 if (replay_get_version() >= 8 && replay_get_version() < 11)
9179 {
9180
2/2
✓ Branch 0 taken 47749536 times.
✓ Branch 1 taken 2652752 times.
50402288 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9181 47749536 down_control_states[i] = raw_control_state[i];
9182 2652752 }
9183
9184
1/2
✓ Branch 0 taken 6818528 times.
✗ Branch 1 not taken.
6818528 if (!replay_is_replaying())
9185 {
9186 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9187 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9188 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9189 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9190 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9191 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9192 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9193 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9194 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9195 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9196 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9197 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9198 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9199 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9200
9201 if(num_joysticks != 0)
9202 {
9203 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9204 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9205 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9206 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9207 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9208 }
9209 else
9210 {
9211 raw_control_state[14] = false;
9212 raw_control_state[15] = false;
9213 raw_control_state[16] = false;
9214 raw_control_state[17] = false;
9215 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9216 }
9217 bool did_bad_cutscene_btn = false;
9218 for(int q = 0; q < 18; ++q)
9219 if(raw_control_state[q] && !active_cutscene.can_button(q))
9220 {
9221 raw_control_state[q] = false;
9222 did_bad_cutscene_btn = true;
9223 }
9224 if(did_bad_cutscene_btn)
9225 active_cutscene.error();
9226 }
9227
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6818525 times.
6818528 if (replay_is_active())
9228 {
9229
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5803310 times.
6818525 if (replay_get_version() < 3)
9230 1015215 replay_poll();
9231
3/4
✓ Branch 0 taken 5803310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4041935 times.
✓ Branch 3 taken 1761375 times.
5803310 else if (replay_is_replaying() && replay_get_version() < 6)
9232 1761375 replay_peek_input();
9233
5/6
✓ Branch 0 taken 4041935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3947327 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1294575 times.
✓ Branch 5 taken 2652752 times.
4041935 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9234 2652752 replay_peek_input();
9235
2/2
✓ Branch 0 taken 5713768 times.
✓ Branch 1 taken 1104757 times.
6818525 if (replay_get_version() == 8)
9236 1104757 update_keys();
9237 6818525 }
9238
9239 // Some test replay files were made before a serious input bug was fixed, so instead
9240 // of re-doing them or tossing them out, just check for that zplay version.
9241
3/4
✓ Branch 0 taken 6818522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6696622 times.
6818528 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9242
2/2
✓ Branch 0 taken 122733396 times.
✓ Branch 1 taken 6818522 times.
129551918 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9243 {
9244 122733396 control_state[i] = raw_control_state[i];
9245
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 73246086 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122733396 if (botched_input && !control_state[i])
9246 47077142 down_control_states[i] = false;
9247 122733396 }
9248
9249 6818522 button_press[0]=rButton(control_state[0],button_hold[0]);
9250 6818522 button_press[1]=rButton(control_state[1],button_hold[1]);
9251 6818522 button_press[2]=rButton(control_state[2],button_hold[2]);
9252 6818522 button_press[3]=rButton(control_state[3],button_hold[3]);
9253 6818522 button_press[4]=rButton(control_state[4],button_hold[4]);
9254 6818522 button_press[5]=rButton(control_state[5],button_hold[5]);
9255 6818522 button_press[6]=rButton(control_state[6],button_hold[6]);
9256 6818522 button_press[7]=rButton(control_state[7],button_hold[7]);
9257 6818522 button_press[8]=rButton(control_state[8],button_hold[8]);
9258 6818522 button_press[9]=rButton(control_state[9],button_hold[9]);
9259 6818522 button_press[10]=rButton(control_state[10],button_hold[10]);
9260 6818522 button_press[11]=rButton(control_state[11],button_hold[11]);
9261 6818522 button_press[12]=rButton(control_state[12],button_hold[12]);
9262 6818522 button_press[13]=rButton(control_state[13],button_hold[13]);
9263 6818522 button_press[14]=rButton(control_state[14],button_hold[14]);
9264 6818522 button_press[15]=rButton(control_state[15],button_hold[15]);
9265 6818522 button_press[16]=rButton(control_state[16],button_hold[16]);
9266 6818522 button_press[17]=rButton(control_state[17],button_hold[17]);
9267 6818522 }
9268
9269 // Returns true if any game key is pressed. This is needed because keypressed()
9270 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9271 35392899 bool zc_key_pressed()
9272 //may also need to use zc_getrawkey
9273 {
9274
7/10
✓ Branch 0 taken 28675726 times.
✓ Branch 1 taken 6717173 times.
✓ Branch 2 taken 6717173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6717173 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5632865 times.
✓ Branch 7 taken 5632865 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2136415 times.
37529314 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9275
4/6
✓ Branch 0 taken 5632865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5632865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4266735 times.
✓ Branch 5 taken 4266735 times.
5632865 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9276
4/6
✓ Branch 0 taken 4266735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4266735 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2755819 times.
✓ Branch 5 taken 2755819 times.
4266735 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9277
4/6
✓ Branch 0 taken 2755819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2755819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2389992 times.
✓ Branch 5 taken 2389992 times.
2755819 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9278
1/2
✓ Branch 0 taken 2389992 times.
✗ Branch 1 not taken.
2389992 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9279
3/4
✓ Branch 0 taken 2274024 times.
✓ Branch 1 taken 115968 times.
✓ Branch 2 taken 2274024 times.
✗ Branch 3 not taken.
2389992 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9280
3/4
✓ Branch 0 taken 2166107 times.
✓ Branch 1 taken 107917 times.
✓ Branch 2 taken 2166107 times.
✗ Branch 3 not taken.
2274024 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9281
3/4
✓ Branch 0 taken 2151616 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2151616 times.
✗ Branch 3 not taken.
2166107 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9282
3/4
✓ Branch 0 taken 2139038 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2139038 times.
✗ Branch 3 not taken.
2151616 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9283
3/4
✓ Branch 0 taken 2137294 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2137294 times.
✗ Branch 3 not taken.
2139038 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9284
3/4
✓ Branch 0 taken 2137221 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2137221 times.
✗ Branch 3 not taken.
2137294 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9285
3/4
✓ Branch 0 taken 2136434 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2136434 times.
✗ Branch 3 not taken.
2137221 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9286
2/4
✓ Branch 0 taken 2136434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2136434 times.
✗ Branch 3 not taken.
2136434 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9287
2/2
✓ Branch 0 taken 2136415 times.
✓ Branch 1 taken 19 times.
2136434 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9288 63347306 return true;
9289
9290 2136415 return false;
9291 8132269 }
9292
9293 133869767 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9294 {
9295 133869767 bool ret = false, drunkstate = false, rawret = false;
9296 133869767 bool* flag = &down_control_states[btn];
9297
2/7
✓ Branch 0 taken 125729005 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8140762 times.
133869767 switch(btn)
9298 {
9299 case btnF12:
9300 ret = zc_getkey(KEY_F12, ignoreDisable);
9301 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9302 eatEntirely = false;
9303 break;
9304 case btnF11:
9305 ret = zc_getkey(KEY_F11, ignoreDisable);
9306 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9307 eatEntirely = false;
9308 break;
9309 case btnF5:
9310 ret = zc_getkey(KEY_F5, ignoreDisable);
9311 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9312 eatEntirely = false;
9313 break;
9314 case btnQ:
9315 ret = zc_getkey(KEY_Q, ignoreDisable);
9316 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9317 eatEntirely = false;
9318 break;
9319 case btnI:
9320 ret = zc_getkey(KEY_I, ignoreDisable);
9321 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9322 eatEntirely = false;
9323 break;
9324 case btnM:
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8140762 times.
8140762 if(FFCore.kb_typing_mode) return false;
9326 8140762 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9327 8140762 eatEntirely = false;
9328 8140762 break;
9329 default: //control_state[] index
9330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125729005 times.
125729005 if(FFCore.kb_typing_mode) return false;
9331
5/6
✓ Branch 0 taken 125258315 times.
✓ Branch 1 taken 470690 times.
✓ Branch 2 taken 2348400 times.
✓ Branch 3 taken 122909915 times.
✓ Branch 4 taken 2348400 times.
✗ Branch 5 not taken.
125729005 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9332
2/2
✓ Branch 0 taken 6791708 times.
✓ Branch 1 taken 118937297 times.
125729005 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9333
4/4
✓ Branch 0 taken 113325251 times.
✓ Branch 1 taken 12403754 times.
✓ Branch 2 taken 5048 times.
✓ Branch 3 taken 12398706 times.
138132759 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9334 125729005 rawret = raw_control_state[btn];
9335 125729005 }
9336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133869767 times.
133869767 assert(flag);
9337
2/2
✓ Branch 0 taken 86417835 times.
✓ Branch 1 taken 47451932 times.
133869767 if(press)
9338 {
9339
2/2
✓ Branch 0 taken 1646643 times.
✓ Branch 1 taken 45805289 times.
47451932 if(peek)
9340 1646643 ret = rButtonPeek(ret, *flag);
9341
3/4
✓ Branch 0 taken 45805289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26119596 times.
✓ Branch 3 taken 19685693 times.
45805289 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9342 26119596 else ret = rButton(ret, *flag, &rawret);
9343 47451932 }
9344
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133869767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133869767 if(eatEntirely && ret) control_state[btn] = false;
9345
3/4
✓ Branch 0 taken 101238710 times.
✓ Branch 1 taken 32631057 times.
✓ Branch 2 taken 101238710 times.
✗ Branch 3 not taken.
133869767 if(drunk && drunkstate) ret = !ret;
9346 133869767 return ret;
9347 133869767 }
9348
9349 6589258 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9350 {
9351 6589258 byte ret = 0;
9352
2/2
✓ Branch 0 taken 4940537 times.
✓ Branch 1 taken 1648721 times.
6589258 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9353
2/2
✓ Branch 0 taken 6588696 times.
✓ Branch 1 taken 562 times.
6589258 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9354
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9355
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9356
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9357
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9358
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9359
2/2
✓ Branch 0 taken 6588821 times.
✓ Branch 1 taken 437 times.
6589258 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9360 6589258 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9361 }
9362
9363 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9364 {
9365 1114 return intbtn&vals;
9366 }
9367
9368 1579380 bool Up()
9369 {
9370 1579380 return getInput(btnUp);
9371 }
9372 100763 bool Down()
9373 {
9374 100763 return getInput(btnDown);
9375 }
9376 193222 bool Left()
9377 {
9378 193222 return getInput(btnLeft);
9379 }
9380 217697 bool Right()
9381 {
9382 217697 return getInput(btnRight);
9383 }
9384 112761 bool cAbtn()
9385 {
9386 112761 return getInput(btnA);
9387 }
9388 1333347 bool cBbtn()
9389 {
9390 1333347 return getInput(btnB);
9391 }
9392 bool cSbtn()
9393 {
9394 return getInput(btnS);
9395 }
9396 46682 bool cLbtn()
9397 {
9398 46682 return getInput(btnL);
9399 }
9400 46682 bool cRbtn()
9401 {
9402 46682 return getInput(btnR);
9403 }
9404 bool cPbtn()
9405 {
9406 return getInput(btnP);
9407 }
9408 bool cEx1btn()
9409 {
9410 return getInput(btnEx1);
9411 }
9412 bool cEx2btn()
9413 {
9414 return getInput(btnEx2);
9415 }
9416 bool cEx3btn()
9417 {
9418 return getInput(btnEx3);
9419 }
9420 bool cEx4btn()
9421 {
9422 return getInput(btnEx4);
9423 }
9424 bool AxisUp()
9425 {
9426 return getInput(btnAxisUp);
9427 }
9428 bool AxisDown()
9429 {
9430 return getInput(btnAxisDown);
9431 }
9432 bool AxisLeft()
9433 {
9434 return getInput(btnAxisLeft);
9435 }
9436 bool AxisRight()
9437 {
9438 return getInput(btnAxisRight);
9439 }
9440
9441 bool cMbtn()
9442 {
9443 return getInput(btnM);
9444 }
9445 bool cF12()
9446 {
9447 return getInput(btnF12);
9448 }
9449 bool cF11()
9450 {
9451 return getInput(btnF11);
9452 }
9453 bool cF5()
9454 {
9455 return getInput(btnF5);
9456 }
9457 bool cQ()
9458 {
9459 return getInput(btnQ);
9460 }
9461 bool cI()
9462 {
9463 return getInput(btnI);
9464 }
9465
9466 127703 bool rUp()
9467 {
9468 127703 return getInput(btnUp, true);
9469 }
9470 127609 bool rDown()
9471 {
9472 127609 return getInput(btnDown, true);
9473 }
9474 127557 bool rLeft()
9475 {
9476 127557 return getInput(btnLeft, true);
9477 }
9478 127093 bool rRight()
9479 {
9480 127093 return getInput(btnRight, true);
9481 }
9482 2987 bool rAbtn()
9483 {
9484 2987 return getInput(btnA, true);
9485 }
9486 128823 bool rBbtn()
9487 {
9488 128823 return getInput(btnB, true);
9489 }
9490 6548031 bool rSbtn()
9491 {
9492 6548031 return getInput(btnS, true);
9493 }
9494 8132269 bool rMbtn()
9495 {
9496 8132269 return getInput(btnM, true);
9497 }
9498 126885 bool rLbtn()
9499 {
9500 126885 return getInput(btnL, true);
9501 }
9502 126880 bool rRbtn()
9503 {
9504 126880 return getInput(btnR, true);
9505 }
9506 6465204 bool rPbtn()
9507 {
9508 6465204 return getInput(btnP, true);
9509 }
9510 bool rEx1btn()
9511 {
9512 return getInput(btnEx1, true);
9513 }
9514 bool rEx2btn()
9515 {
9516 return getInput(btnEx2, true);
9517 }
9518 137531 bool rEx3btn()
9519 {
9520 137531 return getInput(btnEx3, true);
9521 }
9522 137531 bool rEx4btn()
9523 {
9524 137531 return getInput(btnEx4, true);
9525 }
9526 bool rAxisUp()
9527 {
9528 return getInput(btnAxisUp, true);
9529 }
9530 bool rAxisDown()
9531 {
9532 return getInput(btnAxisDown, true);
9533 }
9534 bool rAxisLeft()
9535 {
9536 return getInput(btnAxisLeft, true);
9537 }
9538 bool rAxisRight()
9539 {
9540 return getInput(btnAxisRight, true);
9541 }
9542
9543 bool rF11()
9544 {
9545 return getInput(btnF11, true);
9546 }
9547 bool rQ()
9548 {
9549 return getInput(btnQ, true);
9550 }
9551 bool rI()
9552 {
9553 return getInput(btnI, true);
9554 }
9555
9556 16396273 bool DrunkUp()
9557 {
9558 16396273 return getInput(btnUp, false, true);
9559 }
9560 15269213 bool DrunkDown()
9561 {
9562 15269213 return getInput(btnDown, false, true);
9563 }
9564 9598805 bool DrunkLeft()
9565 {
9566 9598805 return getInput(btnLeft, false, true);
9567 }
9568 8331926 bool DrunkRight()
9569 {
9570 8331926 return getInput(btnRight, false, true);
9571 }
9572 7131727 bool DrunkcAbtn()
9573 {
9574 7131727 return getInput(btnA, false, true);
9575 }
9576 7017752 bool DrunkcBbtn()
9577 {
9578 7017752 return getInput(btnB, false, true);
9579 }
9580 6418174 bool DrunkcEx1btn()
9581 {
9582 6418174 return getInput(btnEx1, false, true);
9583 }
9584 6418194 bool DrunkcEx2btn()
9585 {
9586 6418194 return getInput(btnEx2, false, true);
9587 }
9588 bool DrunkcSbtn()
9589 {
9590 return getInput(btnS, false, true);
9591 }
9592 bool DrunkcMbtn()
9593 {
9594 return getInput(btnM, false, true);
9595 }
9596 bool DrunkcLbtn()
9597 {
9598 return getInput(btnL, false, true);
9599 }
9600 bool DrunkcRbtn()
9601 {
9602 return getInput(btnR, false, true);
9603 }
9604 bool DrunkcPbtn()
9605 {
9606 return getInput(btnP, false, true);
9607 }
9608
9609 bool DrunkrUp()
9610 {
9611 return getInput(btnUp, true, true);
9612 }
9613 bool DrunkrDown()
9614 {
9615 return getInput(btnDown, true, true);
9616 }
9617 bool DrunkrLeft()
9618 {
9619 return getInput(btnLeft, true, true);
9620 }
9621 bool DrunkrRight()
9622 {
9623 return getInput(btnRight, true, true);
9624 }
9625 5376957 bool DrunkrAbtn()
9626 {
9627 5376957 return getInput(btnA, true, true);
9628 }
9629 5392619 bool DrunkrBbtn()
9630 {
9631 5392619 return getInput(btnB, true, true);
9632 }
9633 71669 bool DrunkrEx1btn()
9634 {
9635 71669 return getInput(btnEx1, true, true);
9636 }
9637 71662 bool DrunkrEx2btn()
9638 {
9639 71662 return getInput(btnEx2, true, true);
9640 }
9641 bool DrunkrEx3btn()
9642 {
9643 return getInput(btnEx3, true, true);
9644 }
9645 bool DrunkrEx4btn()
9646 {
9647 return getInput(btnEx4, true, true);
9648 }
9649 bool DrunkrSbtn()
9650 {
9651 return getInput(btnS, true, true);
9652 }
9653 bool DrunkrMbtn()
9654 {
9655 return getInput(btnM, true, true);
9656 }
9657 6047608 bool DrunkrLbtn()
9658 {
9659 6047608 return getInput(btnL, true, true);
9660 }
9661 6044226 bool DrunkrRbtn()
9662 {
9663 6044226 return getInput(btnR, true, true);
9664 }
9665 bool DrunkrPbtn()
9666 {
9667 return getInput(btnP, true, true);
9668 }
9669
9670 8493 void eat_buttons()
9671 {
9672 8493 getInput(btnA, true, false, true);
9673 8493 getInput(btnB, true, false, true);
9674 8493 getInput(btnS, true, false, true);
9675 8493 getInput(btnM, true, false, true);
9676 8493 getInput(btnL, true, false, true);
9677 8493 getInput(btnR, true, false, true);
9678 8493 getInput(btnP, true, false, true);
9679 8493 getInput(btnEx1, true, false, true);
9680 8493 getInput(btnEx2, true, false, true);
9681 8493 getInput(btnEx3, true, false, true);
9682 8493 getInput(btnEx4, true, false, true);
9683 8493 }
9684
9685 // Is true for the _first frame_ of a key press.
9686 // But! it is possible that a script manually sets the value of KeyPress,
9687 // in which case it will be restored to the "true" value based on `key_current_frame`
9688 // and `key_previous_frame` on the next frame.
9689 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9690 {
9691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9693 {
9694 case KEY_F7:
9695 case KEY_F8:
9696 case KEY_F9:
9697 return KeyPress[k];
9698
9699 default:
9700
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9701 }
9702 14 }
9703
9704 // Is true for _every frame_ a key is held down.
9705 // But! it is possible that a script manually sets the value of KeyInput,
9706 // in which case it will be restored to the "true" value based on `key_current_frame`
9707 // on the next frame.
9708 bool zc_getkey(int32_t k, bool ignoreDisable)
9709 {
9710 if(ignoreDisable) return KeyInput[k];
9711 switch(k)
9712 {
9713 case KEY_F7:
9714 case KEY_F8:
9715 case KEY_F9:
9716 return KeyInput[k];
9717
9718 default:
9719 return KeyInput[k] && !disabledKeys[k];
9720 }
9721 }
9722
9723 // Reads (and then clears) the current frame key state directly.
9724 // Scripts can also modify `key_current_frame`.
9725 202 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9726 {
9727
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 200 times.
202 if(zc_getrawkey(k, ignoreDisable))
9728 {
9729 2 _key[k]=key[k]=key_current_frame[k]=0;
9730 2 return true;
9731 }
9732 200 _key[k]=key[k]=key_current_frame[k]=0;
9733 200 return false;
9734 202 }
9735
9736 // Reads the current frame key state directly.
9737 // Scripts can also modify `key_current_frame`.
9738 55313985 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9739 {
9740
2/2
✓ Branch 0 taken 47181688 times.
✓ Branch 1 taken 8132297 times.
55313985 if(ignoreDisable) return key_current_frame[k];
9741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132297 times.
8132297 switch(k)
9742 {
9743 case KEY_F7:
9744 case KEY_F8:
9745 case KEY_F9:
9746 return key_current_frame[k];
9747
9748 default:
9749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8132297 times.
8132297 return key_current_frame[k] && !disabledKeys[k];
9750 }
9751 55313985 }
9752
9753 // Only used for a handful of keys, like tilde and Function keys.
9754 // This state is never read within the game.
9755 // It exists so that all keyboard input still functions during replay,
9756 // without inadvertently doing things like toggling throttling if the player
9757 // presses ~
9758 16264636 bool zc_get_system_key(int32_t k)
9759 {
9760 16264636 return key_system[k];
9761 }
9762
9763 // True for the _first_ frame of a key press.
9764 73190421 bool zc_read_system_key(int32_t k)
9765 {
9766 73190421 return key_system_press[k];
9767 }
9768
9769 1032798163 bool is_system_key(int32_t k)
9770 {
9771
2/2
✓ Branch 0 taken 959607742 times.
✓ Branch 1 taken 73190421 times.
1032798163 switch (k)
9772 {
9773 case KEY_BACKQUOTE:
9774 case KEY_CLOSEBRACE:
9775 case KEY_END:
9776 case KEY_HOME:
9777 case KEY_OPENBRACE:
9778 case KEY_PGDN:
9779 case KEY_PGUP:
9780 case KEY_TAB:
9781 case KEY_TILDE:
9782 73190421 return true;
9783 }
9784 959607742 return is_Fkey(k);
9785 1032798163 }
9786
9787 8132269 void update_system_keys()
9788 {
9789
2/2
✓ Branch 0 taken 1032798163 times.
✓ Branch 1 taken 8132269 times.
1040930432 for (int32_t q = 0; q < 127; ++q)
9790 {
9791
2/2
✓ Branch 0 taken 170777649 times.
✓ Branch 1 taken 862020514 times.
1032798163 if (!is_system_key(q))
9792 862020514 continue;
9793
9794 170777649 key_system[q] = key[q];
9795
1/2
✓ Branch 0 taken 170777649 times.
✗ Branch 1 not taken.
170777649 key_system_press[q] = key_system[q] && !key_system_previous[q];
9796 170777649 key_system_previous[q] = key_system[q];
9797 170777649 }
9798 8132269 }
9799
9800 9237026 void update_keys()
9801 {
9802
2/2
✓ Branch 0 taken 1173102302 times.
✓ Branch 1 taken 9237026 times.
1182339328 for (int32_t q = 0; q < 127; ++q)
9803 {
9804 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9805
1/2
✓ Branch 0 taken 1173102302 times.
✗ Branch 1 not taken.
1173102302 if (!replay_is_replaying())
9806 key_current_frame[q] = key[q];
9807
9808
2/2
✓ Branch 0 taken 1164439575 times.
✓ Branch 1 taken 8662727 times.
1173102302 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9809 1173102302 KeyInput[q] = key_current_frame[q];
9810 1173102302 key_previous_frame[q] = key_current_frame[q];
9811 1173102302 }
9812 9237026 }
9813
9814 bool zc_disablekey(int32_t k, bool val)
9815 {
9816 switch(k)
9817 {
9818 case KEY_F7:
9819 case KEY_F8:
9820 case KEY_F9:
9821 return false;
9822
9823 default:
9824 disabledKeys[k] = val;
9825 return true;
9826 }
9827 }
9828
9829 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9830 {
9831 timer=timer;
9832 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9833 }
9834
9835 // these are here so that copy_dialog won't choke when compiling zelda
9836 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9837 {
9838 return D_O_K;
9839 }
9840
9841 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9842 {
9843 return D_O_K;
9844 }
9845
9846 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9847 {
9848 return D_O_K;
9849 }
9850
9851 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9852 {
9853 return D_O_K;
9854 }
9855
9856 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9857 {
9858 return D_O_K;
9859 }
9860
9861 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9862 {
9863 return D_O_K;
9864 }
9865
9866 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9867 {
9868 return D_O_K;
9869 }
9870
9871 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9872 {
9873 return D_O_K;
9874 }
9875
9876 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9877 {
9878 return D_O_K;
9879 }
9880
9881 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9882 {
9883 return D_O_K;
9884 }
9885
9886 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9887 {
9888 return D_O_K;
9889 }
9890
9891 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9892 {
9893 return D_O_K;
9894 }
9895
9896 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9897 {
9898 return D_O_K;
9899 }
9900
9901 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9902 {
9903 return D_O_K;
9904 }
9905
9906 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9907 {
9908 return D_O_K;
9909 }
9910
9911 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9912 {
9913 return D_O_K;
9914 }
9915
9916 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9917 {
9918 return D_O_K;
9919 }
9920
9921 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9922 {
9923 return D_O_K;
9924 }
9925
9926 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9927 {
9928 return D_O_K;
9929 }
9930
9931 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9932 {
9933 return D_O_K;
9934 }
9935
9936 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9937 {
9938 return D_O_K;
9939 }
9940
9941 /*** end of zc_sys.cc ***/
9942
9943